Check if cells in range are contained in another cell

horizonflame

Board Regular
Joined
Sep 27, 2018
Messages
184
Office Version
  1. 2013
Hi there

I am after some help with searching for a string. If the value in column L is found anywhere in cell A9 I want to enter the cell value (currently a formula). If the value is not found then change the cell to blank.

I've tried the below but it just makes all cells blank!

Your help is appreciated, thank you.

VBA Code:
With Sheets("Data")
For each cell in .Range("L2:L" & LR1)
     If cell.value Like "*" & .Range("A9").value Then
          cell.value = cell.value
     Else
          cell.value = ""
Next cell
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Try it the otherway round
VBA Code:
If .Range("A9").value Like "*" & cell.value & "*"  Then
 
Upvote 0
What do you have in L2 downwards & in A9?
 
Upvote 0
L2-L5 for example is 3001548652, 3001548798, 3001548287, 3001549415

A9 is "3001548652, 3001549415"
 
Upvote 0
With that data it works for me, it matches L2 & L5, but not L3:L4
What is the formula in col L?
 
Upvote 0
Hi @Fluff

My previous code puts this formula in Column L:

.Range("L2:L" & LR4).Formula = "=SUMPRODUCT(('Points'!$A$2:$A$" & LR3 & "=$K2)*('Points'!$C$2:$C$" & LR3 & "))"

Thank you.
 
Upvote 0
Putting that formula into L2:L5 & using the values from post#5 2 of them are converted to values & 2 are cleared.
 
Upvote 0
Hi @Fluff I realised that where the SUMPRODUCT formula ended with a 0 result, it was matching with a 0 in the string creating a false positive.

Thanks for your help!
 
Upvote 0
Glad you sorted it & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,575
Members
449,089
Latest member
Motoracer88

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