Results 1 to 12 of 12

Searching Columns and Copying the respective Rows

Threaded View

  1. #1
    Registered User
    Join Date
    06-01-2011
    Location
    Dayton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    20

    Unhappy Searching Columns and Copying the respective Rows

    I am trying to write a macro inside of Sheet 1 that will search Column J for certain terms one of them being "STEP" Once the search finds that term in Column J, I want it to copy the entire row to Sheet 2. The code I have researched and found doesnt seem to be doing it. Here is the code that I have been using:

    Sub Test()
    Set a = Sheets("Sheet1")
    Set b = Sheets("Sheet2")
    Set c = Sheets("Sheet3")
    Dim x
    Dim z
    
    x = 1
    z = 4
    
    Do Until IsEmpty(a.Range("J" & z))
    
    If a.Range("J" & z) = "STEP" Then
    x = x + 1
    b.Rows(x).Value = a.Rows(z).Value
    
    Else
    
    If a.Range("J" & z) = "SCEP" Then
    x = x + 1
    c.Rows(x).Value = a.Rows(z).Value
    
    End If
    End If
    z = z + 1
    Loop
    
    End Sub
    Last edited by Erenagh; 06-02-2011 at 08:22 AM. Reason: didnt enter my code properly

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