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

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
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,215,036
Messages
6,122,796
Members
449,095
Latest member
m_smith_solihull

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