+ Reply to Thread
Results 1 to 6 of 6

How to make a VBA that self-references a cell and adds from another clel

  1. #1
    Registered User
    Join Date
    02-01-2023
    Location
    FL
    MS-Off Ver
    Microsoft Office 365
    Posts
    6

    How to make a VBA that self-references a cell and adds from another clel

    Hi,

    Essentially what I want to do is to input a value into cell B5. This value will take the difference of the Actual vs Quota (C4 vs B4), and add it to the cell input I put in.

    So the difference is +700. This means that my quota for the next month will not need that +700 since I already hit it. So what cell B5 is doing is taking the input of the cell, lets say 3000, and taking away 700 from it, or adding to it if it was a deficit. This would continue all the way down.

    I want to be able to manually enter any number into B5, and all the way down, and it will update accordingly.

    Unless you know of a formula that does it but i think it is vba because of self reference
    Attached Files Attached Files
    Last edited by parkerryan; 02-02-2023 at 11:28 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    01-07-2022
    Location
    Europe
    MS-Off Ver
    Office 365
    Posts
    473

    Re: How to make a VBA that self-references a cell and adds from another clel

    Hi - I'm guessing this is a continuation of this thread https://www.excelforum.com/excel-for...s-entered.html

    Trying something like this can have unintended consequences as it works counter to how users expect excel to work when you enter data. Something like the following could work, but needs further thought on how to handle
    a) if user changes a value from a previous row, as it won't automatically flow down
    b) errors, such as if text is entered accidentally
    etc

    Please Login or Register  to view this content.
    <<< If you have valued anyone's contributions in this thread, please click * to thank them for their efforts

  3. #3
    Registered User
    Join Date
    02-01-2023
    Location
    FL
    MS-Off Ver
    Microsoft Office 365
    Posts
    6

    Re: How to make a VBA that self-references a cell and adds from another clel

    Hi,

    Could I do somethhing like value input in active cell B5 (let's say value input is 3000) = Range.Select C4 - Range.Select B4 + InputValue (3,000) ?

    Idk how to write that but something like that.

    I am not sure what the code you put does, it didn't do anything for me

  4. #4
    Valued Forum Contributor
    Join Date
    01-07-2022
    Location
    Europe
    MS-Off Ver
    Office 365
    Posts
    473

    Re: How to make a VBA that self-references a cell and adds from another clel

    I think the code does what you are describing.

    To make it work, make sure it's inserted into the Sheet module under Microsoft Excel Objects (see https://www.excel-easy.com/vba/event...t-change-event)

    I've added some explanations on how the code works below
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-01-2023
    Location
    FL
    MS-Off Ver
    Microsoft Office 365
    Posts
    6

    Re: How to make a VBA that self-references a cell and adds from another clel

    Ok I think I got it.. a few more questions

    If Column B Quota is 4,000 and Column C Actuals is 2,000, then it says (positive) 2,000

    If Column B Quota is 2,000 and Column C Actuals is 4,000 then it says (negative) (-2,000)

    What would I write to switch this? If the actuals is over the quota I want it to be positive and if the actuals are under the quota I want it to be negative.

    Also is it possible to make it so all of the cells combined have to equal the total at the very bottom?

    Thank you for all the help man

  6. #6
    Valued Forum Contributor
    Join Date
    01-07-2022
    Location
    Europe
    MS-Off Ver
    Office 365
    Posts
    473

    Re: How to make a VBA that self-references a cell and adds from another clel

    To switch the way the quota calculates, change this line:

    Please Login or Register  to view this content.
    To this:

    Please Login or Register  to view this content.
    There are several methods to have all the cells combine to a desired answer e.g. using adjustment factors. It would help if you can explain in your mind how it would work and we can help advise how to translate the logic to excel

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Make a formula that has specific-cell-references change every n'th row in Excel
    By StijnW1998 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-07-2020, 03:01 PM
  2. Replies: 16
    Last Post: 11-01-2016, 10:26 AM
  3. Replies: 1
    Last Post: 08-19-2015, 11:39 AM
  4. Make a range out of two cell references
    By ChrisNor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2009, 07:23 AM
  5. Replies: 1
    Last Post: 02-07-2006, 10:45 PM
  6. [SOLVED] I wish to make a formula that adds dollars in 1 column if a date .
    By Wayne Cameron in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-21-2005, 03:05 PM
  7. [SOLVED] Make a formula that adds every 4th cell in a column indefinately?
    By Ben Mehling in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-13-2005, 11:05 AM

Tags for this Thread

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