# Dynamic and Static in formula

Merry Christmas and Pre-Happy New Years to All.

Quick question about how to combine a static and dynamic formula in vba.

Here is what I have so far:

Dim r as String
r = target.row

Dim a as String

This is just for the "right hand side of the equation."  The left hand side is already done and fine.

Here goes:

"=((sheet1!T4)/(Sheet2!AF5 + Sheet3!AT3)) "/sheet4!AM" & r & "

So T4, AF5, and AT3 are all static meaning that the program should use these cells all the time.  In other words,  \$T\$4, \$AF\$5, and \$AT\$4.

AM is the dynamic and slides up and down the range relative to the trigger.

Anybody want to take a quick shot at this?  I know I almost have it but I think my problem is around the sheet!4AM part and specifically the "dividing" part  "/".

thanks for you input.
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Microsoft MVP ExcelCommented:
Hello,

if you enter the formula with the .Formula command, then you can place the \$ signs for absolute references, just like in a worksheet formula, so use  \$T\$4, \$AF\$5, and \$AT\$3 and no \$ signs for Sheet4!AM

cheers, teylyn

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
I'll give that a go.  thanks.
Author Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for BostonBob's comment #a39744399

for the following reason:

super quick response.
Owner, Dev-Soln LLCCommented:
I think you selected the wrong answer as the correct one.

If so, click the Request Attention hyperlink at the bottom right corner of your original post, and tell the moderators you would like to reopen the question so that you can assign points to the correct response.
Microsoft MVP ExcelCommented:
Not sure the asker's "thank you" comment is the solution. He is thanking for the advice in comment #39744386, so that should be the accepted answer.
Author Commented:
Still can't get this bad boy to work.  Can you suggest anything?

Worksheets("Basic").Range(a).offset(0,-12).formula = "=((Acc!\$T\$4)/(Q!\$AF\$1011 + constants!\$AT\$3)) "/(Brains!AY" & r & ")

The compiler does not like the right hand of the statement.  Any help is appreciated.

thanks,
"Batchelor", Developer and EE Topic AdvisorCommented:
Watch your double quotes. The one in front of the slash is wrong, and should be moved to the very end of the string.
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.