Macro ActiveSheet.Formula Object doesn't support this property or method error

starheartbeam

New Member
Joined
Aug 8, 2018
Messages
18
I am trying to do the following:

ActiveSheet.Formula = "=IF(TEXT(E2,""YYYYMM"")< text(m2,""yyyymm""),b2&""-""&c2&""-""&d2&""-""&""01-""&(text(m2,""mmm""))&""-""&(text(m2,""yy"")),b2&""-""&c2&""-""&d2&""-""&e2)"



This works when I put it in an excel formula but when I put it in my macro I get "Object doesn't support this property or method" error and I do not know what I need to do to get this to work? Any help would be very helpful.
 
Last edited by a moderator:
This works for me
Code:
ActiveSheet.Range("[COLOR=#ff0000]A2[/COLOR]").Formula = "=IF(TEXT(E2,""YYYYMM"")< text(m2,""yyyymm""),b2&""-""&c2&""-""&d2&""-""&""01-""&(text(m2,""mmm""))&""-""&(text(m2,""yy"")),b2&""-""&c2&""-""&d2&""-""&e2)"
Just change the value in red to the cell you want the formula in
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Things can get tricky when you are trying to add in a formula that has literal quote marks, as those are also used for Text delimiters in VBA. If you do not do it correctly, VBA cannot tell if you want literal quotes marks, or you are just denoting text.

I find that the easiest thing to do in these situations is to turn on your Macro Recorder, and enter one of these formulas on your spreadsheet. Then stop the Macro Recorder and view your recorded code. Thois will show you EXACTLY how the formula needs to look in VBA. So you can just copy and paste that recorded formula into your VBA code.

Thank you! I did this and got it to work.
 
Upvote 0
Thank you! I did this and got it to work.
You are welcome.
And you learned a new little trick for getting VBA code! :)
 
Upvote 0

Forum statistics

Threads
1,223,941
Messages
6,175,541
Members
452,652
Latest member
eduedu

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