Wildcard String Search

I3atnumb3rs

New Member
Joined
Nov 2, 2018
Messages
34
Hello,

I would like to loop column j and if any part of the value in Q equals the string EXCHANGE, I want to concatenate the value in column k the Q, otherwise just put the string value in column q. My wildcard doesn't seem to work and even when the word EXCHANGE is in q and only entering the info in K. Help!

Sub ServiceLevel()
Dim strMyValue As String

strMyValue = "*EXCHANGE*"



Range("A2").Select

Do

ActiveCell.Offset(0, 9).Activate

If ActiveCell.Offset(0, 7).Value = "strMyValue" Then
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[1], "" "", RC[7])"
Else: ActiveCell.FormulaR1C1 = ActiveCell.Offset(0, 1)
End If

ActiveCell.Offset(1, -9).Activate

Loop While ActiveCell.Value <> ""
End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try removing thee quotes from the strMyValue
Code:
If ActiveCell.Offset(0, 7).Value = strMyValue Then
 
Upvote 0
Another thing, you also need to replace the = with Like
 
Upvote 0
Change this line:
If ActiveCell.Offset(0, 7).Value = "strMyValue" Then

To this:
If ActiveCell.Offset(0, 7).Value Like "*EXCHANGE*" Then
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

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