If contains "like" put value in another cell

emukiss10

Board Regular
Joined
Nov 17, 2017
Messages
201
HI Guys!

simple one but I cannot get there :/

If column B contains text like "10,00%" (Ex. "Discount 10,00% was granted")

insert number 21 in column Q of the same row.

Output should look like this

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]O[/TD]
[TD]P[/TD]
[TD]Q[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]BLA BLA 10,00% BLA[/TD]
[TD][/TD]
[TD][/TD]
[TD]21[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]BLA BLA BLA[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]10,00%[/TD]
[TD][/TD]
[TD][/TD]
[TD]21[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]BLA BLA BLA[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Best Regards!
W.
 

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 this formula in Q1:
Code:
=IF(ISNUMBER(SEARCH("10,00%",B1)),21,"")
 
Upvote 0
In VBA please.. Its a part of a macro
In the future, you want to be sure to mention that in your original post so people don't waste time coming up with solutions that don't work for you (not a big deal for this one, as this one was not very complex, but that might not always be the case).

Try this code:
Code:
Sub MyMacro()

    Dim lrow As Long
    Dim r As Long
    
    Application.ScreenUpdating = False
    
'   Find last row in column B with data
    lrow = Cells(Rows.Count, "B").End(xlUp).Row
    
'   Loop through all rows
    For r = 1 To lrow
'       Check entry in column B
        If InStr(Cells(r, "B"), "10,00%") > 0 Then Cells(r, "Q") = 21
    Next r
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0
Thank You it works Perfectly! And forgive my notBeSpecific thing.. Ill keep Your advice in mind next time Ill post.

Best Wishes!
W.
 
Upvote 0
You are welcome.
Glad we were able to help and it works for you.:)
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

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