Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am new to VBA. Below is code I wrote to move data in cells from 9
columns to 31 columns. I need to do this operation about 135 times every two weeks with new data. I get the error message "Run -Time error '1004' Method 'Range' of object '_Global' failed. I would appreciate help with the set r1, r2, r3,r4,r5,r6 ranges. Thank you. Steve G Sub MoveRangePayroll() Dim r1 As Range 'Range of 1st iteration--data to be moved from Dim r2 As Range 'Range of 1st iteration--data will be moved to Dim r3 As Range 'Range of 2nd iteration--data to be moved from Dim r4 As Range 'Range of 2nd iteration--data will be moved to Dim r5 As Range 'Range of 3rd iteration--data to be moved from Dim r6 As Range 'Range of 3rd iteration--data will be moved to Dim dataRnge As Range 'range of all the data to be moved Dim i As Integer 'number of sets of data equal to number of paid staff--i is a counter Set dataRnge = Range("A1:J28") Worksheets("Sheet1").Select With dataRnge i = 1 For i = 1 To 25 Step 4 Set r1 = Range("B(i+1):I(i+3)") Set r2 = Range("J(i):Q(i+2)") Set r3 = Range("J(i+1):Q(i+2)") Set r4 = Range("Ri:Y(i+1)") Set r5 = Range("S(i+1):Z(i+1)") Set r6 = Range("AAi:AEi") Range(r1).Cut Range(r2) Range(r3).Cut Range(r4) Range(r5).Cut Range(r6) i = i + 4 Next End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
move two columns of data to four columns | Excel Discussion (Misc queries) | |||
move data from columns to rows | Excel Worksheet Functions | |||
move multiple columns into single set of columns | Excel Discussion (Misc queries) | |||
Move Data from rows to columns... | Excel Worksheet Functions | |||
vba code to find ssn and move two columns | Excel Programming |