Nested If statement macro

ecla02c

New Member
Joined
Jun 13, 2018
Messages
1
Please help!

I'm stuck with this macro.

When I manually do a nested If statement with OR formula it works fine. But when I convert it to a macro, it errors out. What's frustrating is that this macro worked before with less OR formula statements. The revised one has a total of 30 OR formula statements.

The macro looks at internal codes' characters. If it meets the requirement (OR statement) IF formula will came back with "1" if false it come back "blank".

HTML:
Range("M2").Select
    'ActiveCell.FormulaR1C1 = _
     '   "=IF(OR(LEFT(RC[-2],2)=""03"",LEFT(RC[-2],2)=""18"",LEFT(RC[-2],2)=""19"",LEFT(RC[-2],2)=""23"",LEFT(RC[-2],2)=""24"",LEFT(RC[-2],2)=""29"",LEFT(RC[-2],3)=""S03"",LEFT(RC[-2],3)=""S18"",LEFT(RC[-2],3)=""S19"",LEFT(RC[-2],3)=""S23"",LEFT(RC[-2],3)=""S24"",LEFT(RC[-2],3)=""S29"",LEFT(RC[-2],3)=""P03"",LEFT(RC[-2],3)=""P18"",LEFT(RC[-2],3)=""P19"",LEFT(RC[-2],3)=""P23""" & _
      '  "[-2],3)=""P24"",LEFT(RC[-2],3)=""P29"",LEFT(RC[-2],4)=""NB03"",LEFT(RC[-2],4)=""NB18"",LEFT(RC[-2],4)=""NB19"",LEFT(RC[-2],4)=""NB23"",LEFT(RC[-2],4)=""NB24"",LEFT(RC[-2],4)=""NB29"",LEFT(RC[-2],4)=""DC03"",LEFT(RC[-2],4)=""DC18"",LEFT(RC[-2],4)=""DC19"",LEFT(RC[-2],4)=""DC23"",LEFT(RC[-2],4)=""DC24"",LEFT(RC[-2],4)=""DC29"",LEFT(RC[-2],4)=""DP03"",LEFT(RC[-2],4)=""" & _
       ' "FT(RC[-2],4)=""DP19"",LEFT(RC[-2],4)=""DP23"",LEFT(RC[-2],4)=""DP24"",LEFT(RC[-2],4)=""DP29""),1,"""")"
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,215,453
Messages
6,124,925
Members
449,195
Latest member
Stevenciu

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