excel-vba

Error in selecting range to copy

萝らか妹 提交于 2020-01-11 14:16:29
问题 I need to select a specific range to copy with variable start and end point at each for loop, so used the Range(Cells(x,x), Cells(y,y).Select method. This would give me an error: For i = 1 To 40 Worksheets("BloombergData").Select Worksheets("BloombergData").Range(Cells(5, 2 + 11 * (i - 1)), Cells(4 + Worksheets("Lookup").Cells(i + 1, 3).Value, 11 + 11 * (i - 1))).Select Selection.Copy Worksheets("Data_Rearranged").Range(Cells(6 + Worksheets("Lookup").Cells(i, 3).Value, 4), Cells(5 +

Repeating merged cell range

◇◆丶佛笑我妖孽 提交于 2020-01-11 13:46:09
问题 I have the following basic script that merges cells with the same value in Column R Sub MergeCells() Application.ScreenUpdating = False Application.DisplayAlerts = False Dim rngMerge As Range, cell As Range Set rngMerge = Range("R1:R1000") MergeAgain: For Each cell In rngMerge If cell.Value = cell.Offset(1, 0).Value And IsEmpty(cell) = False Then Range(cell, cell.Offset(1, 0)).Merge GoTo MergeAgain End If Next Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub What I

Excel VBA: Why doesn't any subsequent series get added on?

我的梦境 提交于 2020-01-11 13:40:44
问题 I am trying to plot around 200 series's onto one chart and am trying to use a for loop to plot all the series's for me however, when I run the following code, only the first series (not in the for loop) actually gets onto the chart. All the others that are generated by the for loop do not show up and I have no idea why... Sub Macro3() Dim r As Integer Dim cellName As String Dim first As String Dim second As String Dim newCell As String Dim xAxis As String Dim i As Integer xAxis = "

How to ignore a XML namespace

陌路散爱 提交于 2020-01-11 13:31:32
问题 I have an XML file and this XML file has namespaces declared <CrystalReport xmlns="urn:crystal-reports:schemas:report-detail" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:crystal-reports:schemas:report-detail http://www.businessobjects.com/products/xml/CR2008Schema.xsd"> This is causing problems in my VBA code in Excel. When I remove the namespaces of this line above, it works fine. My question is: How can I ignore this namespace without have to open the xml

Adding Parameters to VBA HTTP Post Request

情到浓时终转凉″ 提交于 2020-01-11 13:07:42
问题 Let me preface my post by noting that I am quite new to leveraging this side of VBA. I am interested in requesting a token from a web service which requires I make an HTTP "POST" request using an authorization code I have personally. I am needing to include this code, among other parameters in my request, but am struggling to do so successfully. Any detail I find online formats their request in Java as follows (all IDs are faked): POST /services/oauth2/token HTTP/1.1 Host: "YourURL.com" grant

Sum column if cells are outside range (range = leftmost value in row + next 11 columns) R or Excel?

时光怂恿深爱的人放手 提交于 2020-01-11 13:06:10
问题 Please see the picture. In the matrix pictured, an entry is considered "New Business" from the leftmost value + the next 11 columns (so 12 months total). I've highlighted this "window" in yellow. Anything to the right of that window is "Return Business". For each column/month, I need to calculate both the New & Return Business. I need a formula or some method to derive these two sums from one column. I only need to be able to get one of these, because then I could just subtract it from the

VBA Macro that filters by month, pastes data for that month only on different sheet

余生颓废 提交于 2020-01-11 13:04:58
问题 I have a sheet (named "UserInput") with data from 1959-2013 (starting at 10/1/1959) i.e.: "UserInput" Sheet Column A Column C Column I DATE UNGAGED FLOW PERM. WITHDRAWAL & PASS Row 24: 10/1/1959 9.3 7.7 10/2/1959 5.2 6.4 10/3/1959 6.3 4.3 10/4/1959 3.8 7.5 ... ... Row 19839: 12/31/2013 5.5 9.1 I need to write a macro that filters by month starting from A24, then pastes the date, 'ungaged flow' (starting at C24) and 'permitted withdrawal and passby' (starting at I24) values for each day to its

Sum column if cells are outside range (range = leftmost value in row + next 11 columns) R or Excel?

橙三吉。 提交于 2020-01-11 13:04:11
问题 Please see the picture. In the matrix pictured, an entry is considered "New Business" from the leftmost value + the next 11 columns (so 12 months total). I've highlighted this "window" in yellow. Anything to the right of that window is "Return Business". For each column/month, I need to calculate both the New & Return Business. I need a formula or some method to derive these two sums from one column. I only need to be able to get one of these, because then I could just subtract it from the

Delete every other row

做~自己de王妃 提交于 2020-01-11 13:00:44
问题 I want to write a loop that deletes entire rows in a sheet to clean-up the file. So if I have row 1 to 10, I want to delete row 1, 3, 5, 7, 9. Sub deleteeveryotherrow() For x = 1 To 10 Rows("x:x").Select Selection.Delete Shift:=xlUp x = x + 2 Next x End Sub 回答1: "x:x" is just a literal string, so will not work as you expect. Use Rows(x & ":" & x).Select instead. You should also consider running the loop backwards from 10 to 1: For x = 9 To 1 Step -2 otherwise you'll get your indexing tangled

Column data moving to right with Excel VBA

浪子不回头ぞ 提交于 2020-01-11 12:39:11
问题 Below is my excl data: A B c .... F G 1 test vb1 testing1 open 2 test1 vb2 testing1 close 2 test2 vb3 testing1 4 test3 vb4 testing1 I want to move F column data to B column and shift B column data to right ,so Before B will be C. How can i do with this using Excel VBA programming. Thanks, Chaitu 回答1: Try this: Option Explicit Sub MoveColumns() With ActiveSheet .Columns("F:F").Cut .Columns("B:B").Insert Shift:=xlToRight .Columns("C:C").Cut .Columns("E:E").Insert Shift:=xlToRight End With