+ Reply to Thread
Results 1 to 7 of 7

VBA Help: Perform Calculations Between Cells with VBA

  1. #1
    Registered User
    Join Date
    08-25-2011
    Location
    Whiteman AFB, MO
    MS-Off Ver
    Excel 2010
    Posts
    3

    VBA Help: Perform Calculations Between Cells with VBA

    I'm trying to figure out how to perform math functions with VBA. My ultimate goal is to create a 3-cell circular reference, with data being able to be entered into any of them.

    It occurred to me that one way of facilitating such a feat would be through the use of textboxes, or by simply referring to the applicable cells in VBA.

    The following are the calculations that I'm trying to perforn in VBA:

    E:E = B:B / C:C
    F:F = E:E + G:G
    G:G = F:F - (C:C / D:D)
    H:H = (F:F - (C:C / D:D)) / (C:C / D:D)
    I:I = D2 * (F:F - (C:C / D:D))
    J:J = D:D * (C:C * (F:F - (B:B / C:C)))
    Attached Files Attached Files
    Last edited by Jambo11; 12-14-2011 at 02:51 AM.

  2. #2
    Registered User
    Join Date
    05-20-2010
    Location
    Fresno, CA
    MS-Off Ver
    2003, 2010
    Posts
    58

    Re: VBA Calculations

    Hi Jambo11,

    Can you upload a sample document containing dummy data and/or your current solution? Also, your thread title is fairly vague. Please consider revising, pursuant to the forum's rules governing the naming of threads.

    1. Use concise, accurate thread titles. Your post title should describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change the title of the thread, click EDIT on the original post, then click the Go Advanced button, then change the title. If two or more hours have passed, the EDIT button will not appear, and you need to ask a moderator to change the title.
    Thanks,
    Ryan



    A word to the wise is infuriating. - Hunter S Thompson

  3. #3
    Forum Contributor wamp's Avatar
    Join Date
    11-10-2008
    Location
    Norway
    MS-Off Ver
    97, 2000 & 2003 (diff. workstations)
    Posts
    184

    Re: VBA Calculations

    this is untested, but I assume you want something like this... ?
    Please Login or Register  to view this content.
    _______________________________________________
    Remember:

    Read the rules!

    Use code tags! Place [CODE] before the first line of code and [/CODE] after the last line of code.

    Mark your post [SOLVED] if it has been answered satisfactorily.
    To do this, click EDIT in your original post, click GO ADVANCED and set the PREFIX. It helps everybody!

    If you are approve (or disapprove) of any members response to your problem, please click the star icon underneath their post and comment. It matters.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA Calculations

    or
    Please Login or Register  to view this content.
    Last edited by snb; 12-13-2011 at 04:56 AM.



  5. #5
    Forum Contributor wamp's Avatar
    Join Date
    11-10-2008
    Location
    Norway
    MS-Off Ver
    97, 2000 & 2003 (diff. workstations)
    Posts
    184

    Thumbs up Re: VBA Calculations

    no but, see...
    your code is simply too clean snb :-p

    (didn't know you could keep it that simple :-) *thumbsup*
    Last edited by wamp; 12-13-2011 at 04:17 AM.

  6. #6
    Registered User
    Join Date
    08-25-2011
    Location
    Whiteman AFB, MO
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: VBA Help: Perform Calculations Between Cells with VBA

    I really appreciate the help from you two.

    I'm finding that either of those macros will work wonders in helping me achieve my goal, but I'm having trouble figuring out how to get it to loop. No doubt, a "Do" loop would be a good approach, but I can't figure the right syntax, or the right "Do" loop to use.

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA Help: Perform Calculations Between Cells with VBA

    It has a builtin loop: you can adapt E1:E200 to E1:E1238 or E12:E345, etc.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1