VBA code to search for matching cell values cut from one sheet and paste to another

Greck71

New Member
Joined
Dec 14, 2017
Messages
3
I have seen many posts like similar to this but none seem to do what I need. I sure hope you can help. I would like to be able to populate sheet3 range I10 to I109 with alpha numeric values (never the same and may not have values for all 100 cells). Then have a macro that will search for an exact match of all these populated values on sheet5 column A. When matches are found found cut from sheet5 (moving all remaining up leaving no blank cells) and paste those rows into sheet6 column A. Finally, sort column A on sheet6 A to Z then go back and clear contents on Sheet3 range I10 to I109.

Thank you for your time!
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi Greck71, welcome to the board.

Give this a try. Copy code to a standard module.

Howard

Code:
Sub Sheet3_Col_I_ET_AL()
Dim s3Rng As Range, c As Range, rngFound As Range
Dim iRow As Long, aRow As Long

iRow = Sheets("Sheet3").Cells(Rows.Count, 9).End(xlUp).Row
aRow = Sheets("Sheet5").Cells(Rows.Count, 1).End(xlUp).Row

Set s3Rng = Sheets("Sheet3").Range("I10:I" & iRow)

For Each c In s3Rng

   With Sheets("Sheet5")
   
      Set rngFound = Sheets("Sheet5").Range("A1:A" & aRow).Find(What:=c, _
                                      LookIn:=xlValues, _
                                      LookAt:=xlWhole, _
                                      SearchOrder:=xlByRows, _
                                      SearchDirection:=xlNext, _
                                      MatchCase:=False)
 
    If Not rngFound Is Nothing Then
    
      rngFound.Cut Sheets("Sheet6").Range("A" & Rows.Count).End(xlUp)(2)
      
     Else
      '
    End If
   
   End With
 
Next
   
   With Sheets("Sheet6").Columns("A")
   
      .Sort Key1:=.Cells(2, 1), Order1:=xlAscending, Header:= _
                                xlYes, Orientation:=xlTopToBottom
   End With
   
   s3Rng = ""
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,256
Messages
6,123,914
Members
449,132
Latest member
Rosie14

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top