+ Reply to Thread
Results 1 to 9 of 9

Copy Text

Hybrid View

aftabn10 Copy Text 11-12-2008, 07:24 AM
royUK Something like this ... 11-12-2008, 07:39 AM
aftabn10 Thanks royUK, ill give that a... 11-12-2008, 08:04 AM
aftabn10 royuk, I get a run-time error... 11-12-2008, 08:09 AM
royUK Please use Code Tags. Have... 11-12-2008, 08:12 AM
aftabn10 Sorry royuk. I do have Sheet2... 11-12-2008, 08:29 AM
royUK No, can you attach the... 11-12-2008, 08:36 AM
aftabn10 royuk, for some odd reason it... 11-12-2008, 08:44 AM
royUK It shouldn't give any error.... 11-12-2008, 08:48 AM
  1. #1
    Forum Contributor
    Join Date
    06-16-2008
    Posts
    287

    Copy Text

    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.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    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

  3. #3
    Forum Contributor
    Join Date
    06-16-2008
    Posts
    287
    Thanks royUK, ill give that a go.

  4. #4
    Forum Contributor
    Join Date
    06-16-2008
    Posts
    287
    royuk, I get a run-time error '1004' on the following line:

    rCopy.Copy Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
    Any ideas why?
    Last edited by royUK; 11-12-2008 at 08:49 AM.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Please use Code Tags.

    Have you got a sheet2?

  6. #6
    Forum Contributor
    Join Date
    06-16-2008
    Posts
    287
    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.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    No, can you attach the workbook

  8. #8
    Forum Contributor
    Join Date
    06-16-2008
    Posts
    287
    royuk, for some odd reason it comes up with the error, but it has now copied the text over. Thanks for all your help!

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1