Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default Moving data in Excel 2003 via VBA

I have a spreadsheet in Excel 2003. I has data in cells A1 thru
J3950. I want to move the data in every other row (the even rows) to
the odd rows, after the existing data in the odd rows. The data in
the odd rows ends in column J. So I want to move the data from
columns A to H in the even rows to columns K to R in the odd rows.
My worksheet is Sheet2a

This is my code:

Sub ShiftEvenRows()

With Worksheets("Sheet2a")
For i = 2 To 6950 Step 2
Set r2 = .Range("A(i):J(i)")
Set r1 = .Range("K(i-1):R(i-1)")
r1.Cut.r2

Next

End With
End Sub

I may have multiple errors. I get the error message "Subscript out of
Range."

Any help would be appreciated.

If anyone is willing to contact me off-line, my email addresses a



and



Thank you in advance.

Steve G



  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,533
Default Moving data in Excel 2003 via VBA

Hi Steve

Try this

Sub ShiftEvenRows()
Application.ScreenUpdating=False
Worksheets("Sheet2a").Activate
For i = 2 To 6950 Step 2
Set r1 = Range(Cells(i, "A"), Cells(i, "J"))
Set r2 = Cells(i - 1, "K")
r1.Cut r2
Next
Application.ScreenUpdating=True
End Sub

Regards,
Per

"Steve G" skrev i meddelelsen
...
I have a spreadsheet in Excel 2003. I has data in cells A1 thru
J3950. I want to move the data in every other row (the even rows) to
the odd rows, after the existing data in the odd rows. The data in
the odd rows ends in column J. So I want to move the data from
columns A to H in the even rows to columns K to R in the odd rows.
My worksheet is Sheet2a

This is my code:

Sub ShiftEvenRows()

With Worksheets("Sheet2a")
For i = 2 To 6950 Step 2
Set r2 = .Range("A(i):J(i)")
Set r1 = .Range("K(i-1):R(i-1)")
r1.Cut.r2

Next

End With
End Sub

I may have multiple errors. I get the error message "Subscript out of
Range."

Any help would be appreciated.

If anyone is willing to contact me off-line, my email addresses a



and



Thank you in advance.

Steve G




Reply
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
Moving a line chart data point revises data table value in Excel ' Ed Smith Charts and Charting in Excel 2 November 16th 12 01:03 PM
Charts moving unexpectly when printing in Excel 2003 JDraffko Charts and Charting in Excel 2 June 17th 08 01:38 PM
Excel 2003 files crashes when saving after moving another excel sh Helvetik Excel Discussion (Misc queries) 0 March 31st 08 05:43 PM
Moving data in Excel 2003 PA New Users to Excel 3 February 26th 08 10:18 PM
moving data in excel without deleting existing data jigna Excel Discussion (Misc queries) 1 January 30th 05 11:35 AM


All times are GMT +1. The time now is 03:18 PM.

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

About Us

"It's about Microsoft Excel"