Updating ActiveCell.Formula to include Relative Cell Reference

bellis

New Member
Joined
Jun 25, 2018
Messages
5
So I have the following script in my macros:
Code:
activecell.Formula = "= IF(LEFT($I6,2)=""17"",""CTRL+G"","""")

Instead of $I6, I need to use Offset so I can call the cell needed (and use the formula in mulitple macros). I thought I should edit swap out $I6 with ActiveCell.Offset(1,-12).Value but it's not working. Here is my erroneous code that I'm trying to fix:
Code:
ActiveCell.Formula = "= IF(LEFT(ActiveCell.Offset(1,-12).Value,2)=""17"",""CTRL+G"","""")"

How do I change the code to use the Offset feature?

Thanks in advance.
Bruce
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Code:
ActiveCell.Formula = "= IF(LEFT(" & ActiveCell.Offset(1, -12).Value & ",2)=""17"",""CTRL+G"","""")"
 
Upvote 0
Thanks, JoeMo. I would not have figured that out. When I grow up I want to be like you ;-) You are an awesome answerer!
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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