LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Help in code Steve G wrote to move data from 4 columns to 21 columns

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
move two columns of data to four columns PB Excel Discussion (Misc queries) 1 February 24th 10 12:54 AM
move data from columns to rows bill gras Excel Worksheet Functions 3 November 21st 09 01:46 AM
move multiple columns into single set of columns mrg9999 Excel Discussion (Misc queries) 1 September 25th 07 05:08 AM
Move Data from rows to columns... Dan B Excel Worksheet Functions 2 January 6th 06 04:47 PM
vba code to find ssn and move two columns rozb Excel Programming 2 April 10th 04 01:43 PM


All times are GMT +1. The time now is 04:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"