Need help comparing two cell values

pltom55

New Member
Joined
Oct 6, 2014
Messages
27
I'm having an issue when I try and compare two cell values.

For example my code looks like
if Range("B3").value = Range("B4").value then
do something
Else
do something else

So in this case
Range("B3").value = "1501-23" and Range("B4").value="1501-23 "
it looks like it would work but it doesn't since the value in B4 has an extra space at the end of the value.
I would use another function to compare/look for a match, if they both have the value "23", but this is a dynamic macro and they values are constantly changing.\
Any suggestions how i would be able to solve this, or incorporate a wildcard somehow?

Thanks
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Maybe something like

If Application.Trim(Range("B3").Value) = Application.Trim(Range("B4").Value) Then

M.
 
Upvote 0

Forum statistics

Threads
1,215,350
Messages
6,124,431
Members
449,158
Latest member
burk0007

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