Hi, i am looking to write a macro to copy text from every 3rd row in my worksheet and then paste this elsewhere. How is this possible?
Thanks in advance.
Hi, i am looking to write a macro to copy text from every 3rd row in my worksheet and then paste this elsewhere. How is this possible?
Thanks in advance.
Something like this
![]()
Dim R As Long Dim RwCnt As Long Dim rCopy As Range With ActiveSheet RwCnt = .UsedRange.Rows.Count For R = RwCnt To 1 Step -3 If rCopy Is Nothing Then Set rCopy = .Cells(R, 1).EntireRow Else: Set rCopy = Union(rCopy, .Cells(R, 1).EntireRow) End If Next R rCopy.Copy Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) End With
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
Thanks royUK, ill give that a go.
royuk, I get a run-time error '1004' on the following line:
Any ideas why?![]()
rCopy.Copy Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
Last edited by royUK; 11-12-2008 at 08:49 AM.
Please use Code Tags.
Have you got a sheet2?
Sorry royuk. I do have Sheet2 and Sheet3 so thats why i dont understand why it comes up with the error. Any ideas?
Thanks once again.
No, can you attach the workbook
royuk, for some odd reason it comes up with the error, but it has now copied the text over. Thanks for all your help!
It shouldn't give any error. Try this
![]()
Dim R As Long Dim RwCnt As Long Dim rCopy As Range With ActiveSheet RwCnt = .UsedRange.Rows.Count For R = RwCnt To 1 Step -3 If rCopy Is Nothing Then Set rCopy = .Cells(R, 1).EntireRow Else: Set rCopy = Union(rCopy, .Cells(R, 1).EntireRow) End If Next R With Sheet2 rCopy.Copy .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0) End With End With
Last edited by royUK; 11-12-2008 at 08:51 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks