Thread: Copy Special
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Copy Special

Actually, there were two problems with the code.

Sub CopyData()
Dim k As Long, j As Long, i As Long
k = Worksheets.Count
Worksheets.Add After:=Worksheets(k)
j = 1
For i = 1 To k
Worksheets(i).Range("B21:O25").Copy _
Worksheets(k + 1).Cells(j, 1)
j = j + 5
Next
End Sub

was tested and worked for me.


You could actually do away with J and just use I alone:

Sub CopyData()
Dim k As Long, j As Long, i As Long
k = Worksheets.Count
Worksheets.Add After:=Worksheets(k)

For i = 1 To k
Worksheets(i).Range("B21:O25").Copy _
Worksheets(k + 1).Cells((i - 1) * 5 + 1, 1)
Next
End Sub

--
Regards,
Tom Ogilvy



"bm4466" wrote:


Hey Tom,
First, thank you very much. Shouldnt I keep two variables though.
I see that J is incremented, but it seems as though I am always pasting
at (1,j) Is one the column? I thought it should be (j,j+5), but I am
really not sure.
Thanks, Ben


--
bm4466
------------------------------------------------------------------------
bm4466's Profile: http://www.excelforum.com/member.php...o&userid=33949
View this thread: http://www.excelforum.com/showthread...hreadid=537244