Formula works but can't record

zcemf64

New Member
Joined
Aug 3, 2011
Messages
10
Hi,

My formula works when I type it in. However, when i try recording it "unable to record macro" appears. I read somewhere that excel doesn't record macros if the cell has more than 255 characters.

=IF(OR(AND(AND($N$2>=1,$N$2<=179),(AND(E2>=181,E2<=359))),(AND(AND($N$2>=181,$N$2<=359),(AND(E2>=1,E2<=179))))),"OPP",IF(OR(AND(AND($N$2>=1,$N$2<=179),(AND(E2>=1,E2<=179))),(AND(AND($N$2>=181,$N$2<=359),(AND(E2>=181,E2<=359))))),"SAME",IF(OR(OR($N$2=0,$N$2=180),(OR((E2=0),(E2=180)))),"VER","")))

I tried typing this in VBA but "compile error: expected: end of statement pops up".
Range("I2").Select
ActiveCell.Formula = _
"=IF(OR(AND(AND($N$2>=1,$N$2<=179),(AND(E2>=181,E2<=359))),(AND(AND($N$2>=181,$N$2<=359),(AND(E2>=1,E2<=179))))),"OPP",IF(OR(AND(AND($N$2>=1,$N$2<=179),(AND(E2>=1,E2<=179))),(AND(AND($N$2>=181,$N$2<=359),(AND(E2>=181,E2<=359))))),"SAME",IF(OR(OR($N$2=0,$N$2=180),(OR((E2=0),(E2=180)))),"VER","")))"

I was wondering if anyone could help me? Would really appreciate it.
Thanks
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
When encoding formulas or any other string including the double quote character, you have to repeat them

try running the following to see what I mean

Code:
Sub test3()
    myStr = "My word is ""test"""
    Debug.Print myStr
End Sub

HTH
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,267
Members
452,902
Latest member
Knuddeluff

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