+ Reply to Thread
Results 1 to 9 of 9

Find string in column and paste corresponding row into other sheet

Hybrid View

  1. #1
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Find string in column and paste corresponding row into other sheet

    I don't know. Will this do?

    Sub With_AutoFilter_A()
        Dim lr As Long
        Application.ScreenUpdating = False
        lr = Sheets("SourceData").Cells(Rows.Count, 1).End(xlUp).Row
    
        With Sheets("SourceData")
            .AutoFilterMode = False
            .Range("A1:A" & lr).AutoFilter field:=1, Criteria1:="11-11-222"
            With Range("A:A, B:B, D:D").SpecialCells(12)
                .SpecialCells(2).Copy Sheets("Parts").Cells(Rows.Count, "A").End(xlUp)(2)
            End With
            .AutoFilterMode = False
        End With
    
        Application.ScreenUpdating = True
    End Sub
    Maybe a slight change in AB33's code will be better.

  2. #2
    Registered User
    Join Date
    08-27-2013
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    30

    Re: Find string in column and paste corresponding row into other sheet

    Untested...

    Option Explicit

    Sub CopyRowToAnotherSheet()
    Dim strFind As String
    Dim NextRow As Long
    Dim rngFound As Range
    Dim wsSource As Worksheet
    Dim wsResult As Worksheet
    Dim CL as Variant

    'Reset Result sheet
    Sheets("Parts").Rows("2:" & Rows.Count).ClearContents
    Application.ScreenUpdating = False

    'Main Code

    Set wsSource = Sheets("SourceData")
    Set wsResult = Sheets("Parts")
    Set rngFound = wsSource.Range("A1:A15000")

    NextRow = wsResult.Range("A" & Rows.Count).End(xlUp).Row
    strFind = "11-11-222"
    For each CL in RngFound
    If instr(CL.Value, "|" & SrtFind) > 0 then
    NextRow = NextRow + 1
    rngFound.EntireRow.Copy wsResult.Range("A" & NextRow)
    end if
    Next CL
    End Sub
    Last edited by briguin; 08-27-2013 at 11:12 PM.

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Find string in column and paste corresponding row into other sheet

    Or maybe like this.

    Sub Use_Union()
        Dim lr As Long, c As Range
        Application.ScreenUpdating = False
        lr = Sheets("SourceData").Cells(Rows.Count, 1).End(xlUp).Row
        With Sheets("SourceData")
            .AutoFilterMode = False
            .Range("A1:A" & lr).AutoFilter field:=1, Criteria1:="11-11-222"
            For Each c In .Range("A2:A" & lr).SpecialCells(12)
                .Application.Union(c, c.Offset(, 1), c.Offset(, 3)).Copy Sheets("Parts").Cells(Rows.Count, "A").End(xlUp)(2)
            Next c
            .AutoFilterMode = False
        End With
        Application.ScreenUpdating = True
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] find value in column A, paste corresponding Column B value to another sheet.
    By A1212 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-28-2012, 07:06 PM
  2. [SOLVED] find last value in column and copy then paste to another sheet
    By AZZ70 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-23-2012, 10:12 AM
  3. Find text in column, copy next row and paste in new sheet
    By MikeTiplady in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-10-2009, 04:26 PM
  4. how to find Certain String in a column, select/Copy the cell till another String
    By excelkeechak in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-18-2009, 10:59 AM
  5. Replies: 8
    Last Post: 03-14-2006, 11:13 AM

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