Pasting Formula's While Recording Macros

cmcclamroch

New Member
Joined
Jan 30, 2015
Messages
2
I would like to know the easiest way to paste a formula while recording a macro -

I have tried referencing the formula from another cell and pasting it in that way and it does not work.
Also tried pasting from text file which does not work either. I've tried various methods from other threads on this site with similar issues and none of them work.

I have tried to enter the following into the macro but it is not working for me either... I get a compile syntax error.

Sub test()
Range("Cell Reference").Formula = "Formula Here"
End Sub

The formula works when I paste it into excel from notepad, but for some reason it won't work if I try to paste it into the macro - here is the formula.

=IF(K2<=DATE(2014,5,31),12,IF(K2<=DATE(2014,6,30),14,IF(K2<=DATE(2014,7,31),13,IF(K2<=DATE(2014,8,31),12, IF(K2<=DATE(2014,9,30), 11,IF(K2<=DATE(2014,10,31),10,IF(K2<=DATE(2014,11,30),9,IF(K2<=DATE(2014,12,31),8,IF(K2<=DATE(2015,1,31),7,IF(K2<=DATE(2015,2,28),6,IF(K2<=DATE(2015,3,31),5,IF(K2<=DATE(2015,4,30),4,IF(K2<=DATE(2015,5,31),3,"see notes")))))))))))))


I'm obviously doing something wrong
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
When recording the macro you should have already wrote your formula in the cell that will be populated with it when the macro runs....after starting the reecording select the cell and then copy the formula within the Formula editor toolbar then paste it back into the cell where you want the macro to insert formula the macro will generate a VBS Formula for you.

You will need to clean up the macro by removing the steps of copying the formula leaving only the select cell and paste of formula
 
Last edited:
Upvote 0
When recording the macro you should have already wrote your formula in the cell that will be populated with it when the macro runs....after starting the reecording select the cell and then copy the formula within the Formula editor toolbar then paste it back into the cell where you want the macro to insert formula the macro will generate a VBS Formula for you.

You will need to clean up the macro by removing the steps of copying the formula leaving only the select cell and paste of formula

Thank you. Could you please instruct me on specifics of how to "copy the formula within the Formula editor toolbar" I'm on the Formula ribbon and don't see a copy or paste option there.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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