Cut/Paste variable


Posted by Bj on May 03, 2001 6:39 AM

I have a query that needs ran every so often. The data can
be anywhere from 2xxx to >5xxx rows by 5 columns.

What I need done, go down every 47 rows, cut from 47 on to the end
then go to G1, Paste, then go down 47 from G1, select G47:K(End) cut it and put in
A50 then repeat the process. Long story short, I need a two column report.

I will attach the code I have so far, it might explain
what I am trying to do better. Thanks! (I have a feeling
someone is going to tell me to click 'Format', '?', '?')

Sub Format()
'5/3/01 Bob Jeffery
Dim X As Integer
Dim LastColumn As Integer
Dim LastRow As Integer

'LastColumn = Range("A1").End(xlToRight).Column
LastRow = Range("A65536").End(xlUp).Row
For X = 1 To LastRow
Range("A" & X + 47, "E" & X + 47).Select
Selection.Cut

Range("G" & X).Select
ActiveSheet.Paste
X = X + 47
Next X

'MsgBox LastColumn & Chr(10) & LastRow

End Sub



Posted by Dave Hawley on May 03, 2001 8:09 AM

Range("G" & X).Select ActiveSheet.Paste X = X + 47


Hi Bj

Tried this once (bed time) and it worked. You can Step a Loop with any desired number.


Sub Format()
'5/3/01 Bob Jeffery
Dim X As Integer
Dim LastColumn As Integer
Dim LastRow As Integer

LastRow = Range("A65536").End(xlUp).Row

For X = 1 To LastRow Step 47
Range("A" & X & ":G" & X).Cut _
Destination:=Range("G" & X)
Next X

Application.CutCopyMode = False
End Sub


Dave

OzGrid Business Applications