Problem with IF...THEN condttion in VBA

UpnDown

New Member
Joined
Aug 3, 2014
Messages
5
I have cell A6 with a formula that produces a text message with a record number when there exists a content match of a SS # in cell B10 within a defined range of cells: =IF(MATCH($B$10,Curr_Cycle_SS_Nos,0)>0,"SS # matches record "&MATCH($B$10,Curr_Cycle_SS_Nos,0)&" in batch.","") The formula works fine but I cannot seem to create an IF...THEN statement in my macro that will match the TRUE state of the condition. I'm doing this to produce a message box with instructions in that situation. E.g. I have tried using If (Len("A6") > 0) Then... Even though that expression will evaluate properly in a cell on the spreadsheet (without the " marks) it will not work in my macro. I've tried many different tests besides the LEN function with different syntax but I'm lost.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I have cell A6 with a formula that produces a text message with a record number when there exists a content match of a SS # in cell B10 within a defined range of cells: =IF(MATCH($B$10,Curr_Cycle_SS_Nos,0)>0,"SS # matches record "&MATCH($B$10,Curr_Cycle_SS_Nos,0)&" in batch.","") The formula works fine but I cannot seem to create an IF...THEN statement in my macro that will match the TRUE state of the condition. I'm doing this to produce a message box with instructions in that situation. E.g. I have tried using If (Len("A6") > 0) Then... Even though that expression will evaluate properly in a cell on the spreadsheet (without the " marks) it will not work in my macro. I've tried many different tests besides the LEN function with different syntax but I'm lost.

<code>Found it, thanks. I should have used Len(Range("A6").Value2)</code>
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,834
Members
449,471
Latest member
lachbee

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