Help adding formula to Macros (with relative reference)...

bellis

New Member
Joined
Jun 25, 2018
Messages
5
I have my Macros working well but need to make it paste a formula in the active cell. I've looked at several posts but have only become more confused. Still a newbie - I've mastered copy/paste and slight tweaks but this is confounding me.:confused:

My formula to include is: =IF(LEFT($I6,2)="17","CTRL+G","")

Here is my macros:

Sub MoveSession06_CTRL_g()​
'​
' MoveSession06_CTRL_g Macro​
'​
' Keyboard Shortcut: Ctrl+g​
'​
Range(ActiveCell.Offset(1, -30), ActiveCell.Offset(1, -25)).Activate​
Selection.Copy​
ActiveCell.Offset(-1, 30).Select​
ActiveSheet.Paste​
ActiveCell.Offset(1, 0).Select​
Selection.EntireRow.Delete​
ActiveCell.Offset(-1, 6).Select

---> I need the formula to go here <-----

End Sub​

Thanks in advance for your help.
Bruce
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Add this line where you need the formula:
Code:
activecell.Formula = "= IF(LEFT($I6,2)=""17"",""CTRL+G"","""")
 
Upvote 0
Since the cell reference isn't updating in the script (I naively thought it would), I need to make get the offset value. Here is what I think it should be but can't figure out what I have wrong:


ActiveCell.Formula = "= IF(LEFT(ActiveCell.Offset(1,-12).Value,2)=""17"",""CTRL+G"","""")"

How do I tweak it to work?

Thanks,
Bruce
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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