Consulting

Results 1 to 4 of 4

Thread: Repeat Search Function

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Feb 2013
    Posts
    30
    Location

    Repeat Search Function

    Hi,
    I have a long list of incomplete names in "sheet2" which i need to search in "sheet1" which have complete information and paste it into "sheet2". If search doesn't find suitable pair go back to "sheet2" and picks the next value. Repeat this till it finds a blank cell. I have recorded the macro. Can somebody help me in making this code in such a way that it repeats itself until the list is complete.



    Selection.Copy
        Sheets("Sheet1").Select
        Range("A1").Select
        Cells.Find(What:="abc", After:=ActiveCell, LookIn:=xlFormulas2, LookAt _
            :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            False, SearchFormat:=False).Activate
        Range("A2:C2").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Sheet2").Select
        Range("A1").Select
        Cells.FindNext(After:=ActiveCell).Activate
        Range("B2").Select
        ActiveSheet.Paste
        Range("A3").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Sheet1").Select
        Range("A1").Select
        Cells.Find(What:="ijk", After:=ActiveCell, LookIn:=xlFormulas2, LookAt _
            :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            False, SearchFormat:=False).Activate
        Sheets("Sheet2").Select
        Range("A4").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Sheet1").Select
        Range("A1").Select
        Cells.Find(What:="xyz hol", After:=ActiveCell, LookIn:=xlFormulas2, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
        Range("A3:C3").Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Sheet2").Select
        Range("A1").Select
        Cells.FindNext(After:=ActiveCell).Activate
        Range("B4").Select
        ActiveSheet.Paste
    Range("A4").Select
        Application.CutCopyMode = False
    End Sub

    Thanks
    Attached Files Attached Files
    Last edited by Aussiebear; 11-25-2022 at 12:47 AM. Reason: You also forgot to enclose your code with code tags

Tags for this Thread

Posting Permissions

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