Formula in Macro

G-Matriix

Board Regular
Joined
Sep 20, 2006
Messages
139
Hello All,

I am trying to have my macro put in a formula and I am getting a error. The formula I was trying to put in was this:
Code:
=IF(AND(OR(X2>0,Y2>0),(AND(AE2<=0,AF2<=0))),"Late PU",IF(AND(AND(X2<=0,Y2<=0),(OR(AE2>0,AF2>0))),"Late Del",IF(AND(OR(X2>0,Y2>0),(OR(AE2>0,AF2>0))),"Both",IF(AND(X2<=0,Y2<=0,AE2<=0,AF2<=0,AH2<>""),"LRC","NONE"))))

I have it in VB as:
Code:
Range("BV2").Select
ActiveCell.FormulaR1C1 = "=IF(AND(OR(RC[-52]>0,RC[-51]>0),(AND(RC[-45]<=0,RC[-44]<=0))),"Late PU",IF(AND(AND(RC[-52]<=0,RC[-51]<=0),(OR(RC[-45]>0,RC[-44]>0))),"Late Del",IF(AND(OR(RC[-52]>0,RC[-51]>0),(OR(RC[-45]>0,RC[-44]>0))),"Both",IF(AND(RC[-52]<=0,RC[-51]<=0,RC[-45]<=0,RC[-44]<=0,RC[-42]<>""),"LRC","NONE"))))"
Selection.AutoFill Destination:=Range("BV2:BV5000"), Type:=xlFillDefault

However, It is giving me a error. I imagine that the formula is too long but I am not sure. Any Ideas??

Please help!

Thanks
 
How about a find " and replace with "" in the VBA editor?

yah, the double quotes should do the same thing has chr(34)

IDK why I didn't think about the find/replace though.. :oops:

would of saved me 10 minutes
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,214,791
Messages
6,121,611
Members
449,038
Latest member
apwr

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