Help prevent "@" from being added to VBA written OFFSET formulas

braindiesel

Well-known Member
Joined
Mar 16, 2009
Messages
571
Office Version
  1. 365
  2. 2019
  3. 2010
Platform
  1. Windows
I have code writing a complex function... what the formula does is irrelevant...
ActiveCell.Formula = "=HOUR(SMALL((OFFSET($A$2,MATCH(F3,$A$3:$A$" & myBot & ",0),1,COUNTIF($A$3:$A$" & myBot & ",F3),1))*(OFFSET($A$2,MATCH(F3,$A$3:$A$" & myBot & ",0),2,COUNTIF($A$3:$A$" & myBot & ",F3),1)=1),ROWS($G$3:G3)+COUNTBLANK(OFFSET($A$2,MATCH(F3,$A$3:$A$" & myBot & ",0),2,COUNTIF($A$3:$A$" & myBot & ",F3),1))))"

In the cell, the macro writes what I want but adds in two @ characters
=HOUR(SMALL((@OFFSET($A$2,MATCH(F3,$A$3:$A$12,0),1,COUNTIF($A$3:$A$12,F3),1))*(@OFFSET($A$2,MATCH(F3,$A$3:$A$12,0),2,COUNTIF($A$3:$A$12,F3),1)=1),ROWS($G$3:G3)+COUNTBLANK(OFFSET($A$2,MATCH(F3,$A$3:$A$12,0),2,COUNTIF($A$3:$A$12,F3),1))))

It results in a NUM! error.
When I remove the 2 added @ symbols, the formula works perfectly

How do I prevent Excel from breaking my formula
 
The OP does not have his version in his profile so this did not occur to me. Thanks.
A problem with a fair few posters at the moment I'm afraid ?
Happy the info Helped.

I teach Microsoft Office. I have all of the versions but living in 365 now
It would be a great help to the responders if you could update your profile when you get time. Thanks ;)
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
A problem with a fair few posters at the moment I'm afraid ?
Happy the info Helped.


It would be a great help to the responders if you could update your profile when you get time. Thanks ;)
Looking for where to put in info now.
 
Upvote 0
Click Where your Avatar and UserName is at the top of the page and it is under Account Details
 
Upvote 0

Forum statistics

Threads
1,215,040
Messages
6,122,806
Members
449,095
Latest member
m_smith_solihull

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