Results 1 to 4 of 4

Macro code error: code is near complete

Threaded View

  1. #1
    Registered User
    Join Date
    12-06-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    6

    Macro code error: code is near complete

    Hi, I have written a macro code as below, however, there seems to be an error.

    I am trying to select all rows in sheet 1 with an X in column E to have their respective columns F, G, H & I to be copied and pasted into sheet 2 starting with cell A1, but sheet 2 should not contain any blank rows.

    Can anyone pls help to fine tune the macro?

    Many thanks.


    
    Sub Copy_Rows()
      
    'Copy rows containing X
    
    Sheets("Sheet1").Select
    For Each r In Sheets("Sheet1").UsedRange.Rows
        n = r.Row
            If Sheets("Sheet1").Cells(n, 5) = "X" Then
            Sheets("Sheet1").Range(Cells(n, 6), Cells(n, 9)).Copy
            Sheets("Sheet2").Select
            Range("A1").Select
            Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks _
                :=False, Transpose:=False
                Else
        End If
        Next r
    
    End Sub
    Last edited by kashshaikh; 12-11-2011 at 10:02 PM.

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