Find Function VBA

hercules89

New Member
Joined
Jan 24, 2019
Messages
3
Hi,
I have a spreadsheet and I am trying to write a macro that searches based on whether a value in column I on sheet 1 appears in any cell in column G on sheet 2 and loop through al visible rows on a filtered range.
- if value in “12345” in cell I2 matches any cell between G3 and then last cell in column G on sheet 2 (number of cells in column G may change daily) then populate K2 with ‘accepted’
- If value doesn’t appear then populate cell K2 with ‘not accepted’
- I need this to perform this search on each filtered value cell in column I

I don’t have a clue where to start with the code for this so sorry for the lack of code, hopefully some expert can help!

Thanks,
Herc
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
How about
Code:
Sub hercules89()
   Dim Cl As Range
   Dim Ws1 As Worksheet, Ws2 As Worksheet
   
   Set Ws1 = Sheets("Sheet1")
   Set Ws2 = Sheets("Sheet2")
   With CreateObject("scripting.dictionary")
      For Each Cl In Ws2.Range("G3", Ws2.Range("G" & Rows.Count).End(xlUp))
         .Item(Cl.Value) = Empty
      Next Cl
      For Each Cl In Ws1.Range("I2", Ws1.Range("I" & Rows.Count).End(xlUp)).SpecialCells(xlVisible)
         If .Exists(Cl.Value) Then Cl.Offset(, 2).Value = "Accepted" Else Cl.Offset(, 2).Value = "Not Accepted"
      Next Cl
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,029
Messages
6,128,403
Members
449,448
Latest member
Andrew Slatter

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