Search an array

Damo10

Active Member
Joined
Dec 13, 2010
Messages
460
Hi,

I have written some code to add items to an array, what I would like to do now is to check if any of the cell contents in worksheet Codes a variable length range from A1 matches any of the values in the array, if it does then I would like the value of cell B in that row change to "Yes"

here is the code I have so far

Code:
Sub test()
    Dim codes
    Dim x As Long
    Dim ws As Worksheet
    Dim ws1 As Worksheet
 
    Set ws = Sheets("Data")
    Set ws1 = Sheets("Codes")
 
    codes = ws.Range(ws.Range("A1"), ws.Range("A" & Rows.Count).End(xlUp))
    For x = LBound(codes) To UBound(codes)
    Next x
End Sub

Any help would be great

Regards Damian
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
This doesn't use your array but I think it does what you want. Provide more details if it doesn't meet your needs.

Test in a copy of your workbook.

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> CheckValues()<br>    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>    <SPAN style="color:#00007F">With</SPAN> Sheets("Codes")<br>        .Columns("B").Insert<br>        <SPAN style="color:#00007F">With</SPAN> .Range("A1", .Range("A" & .Rows.Count).End(xlUp)).Offset(, 1)<br>            .Formula = "=IF(COUNTIF(Data!A:A,A1),""Yes"",C1)"<br>            .Offset(, 1).Value = .Value<br>            .EntireColumn.Delete<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,762
Members
452,940
Latest member
rootytrip

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