Solved

Dynamic and Static in formula

Posted on 2013-12-28
7
311 Views
Last Modified: 2013-12-29
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
a = Target.Address

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.
0
Comment
Question by:BostonBob
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 50

Accepted Solution

by:
Ingeborg Hawighorst (Microsoft MVP / EE MVE) earned 500 total points
ID: 39744386
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
0
 

Author Comment

by:BostonBob
ID: 39744399
I'll give that a go.  thanks.
0
 

Author Comment

by:BostonBob
ID: 39744598
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.
0
RoboForm Secure Password Management System

RoboForm Everywhere - Superb Browser Support
Windows / Apple / IOS / Android / Linux / Chrome OS
Use different complex passwords everywhere
Best Secure Password Management by far
Synchronize all of your devices instantly
Safe, Secure & Highly Recommended!

 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39744593
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.
0
 
LVL 50
ID: 39744599
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.
0
 

Author Comment

by:BostonBob
ID: 39744789
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,
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 39744861
Watch your double quotes. The one in front of the slash is wrong, and should be moved to the very end of the string.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question