+ Reply to Thread
Results 1 to 3 of 3

Add calculation to a macro that runs automatically when a cell value changes.

  1. #1
    Registered User
    Join Date
    09-09-2013
    Location
    Quad Cities Illinois
    MS-Off Ver
    Excel 2010
    Posts
    4

    Add calculation to a macro that runs automatically when a cell value changes.

    Hi,

    I created a macro that checks to see if user eneterd N/A in cell W4, if so, I want to take the value that is in cell v4 divide it by a number (in this case a 6) then add the result of the division to cell v5. Once the division is completed, I am changing the value in v4 to zero.

    Not sure if this is possible since I am using Private Sub Worksheet_change (ByVal Target As Range). Below is what I have so far, I know its not much, but I am at a lost of how to proceed.

    Thanks for any help.

    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 09-10-2013 at 11:58 PM. Reason: added code tags as a courtesy to first-time poster

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Add calculation to a macro that runs automatically when a cell value changes.

    Welcome to the Forum redhead1!

    Please note that our rules require code tags around code to preserve spacing and readability. Because it is your first post I won't take any action, and I have corrected your post. However, please take the time to read all the rules (there aren't that many). I have noted the code tag rule below.

    I believe this does what you need. Note that I have used the notation [V4] which is equivalent to Range("V4") but for some reason isn't used much.

    A couple of notes: I took you very literally when you said "add the result of the division to cell v5." If you really meant "put the result of the division in cell v5" then you need to make what I hope is an obvious change. I made the 6 a named constant to make it easier to track it in the code, and find it if you need to change it later.

    Please Login or Register  to view this content.
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    09-09-2013
    Location
    Quad Cities Illinois
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Add calculation to a macro that runs automatically when a cell value changes.

    Thank you for the input and I am sorry about the code violation. I won't let it happen again.

+ 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] Macro runs perfectly, but dialog box doesn't close automatically
    By Bunnyla in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-29-2012, 01:12 PM
  2. Automatically runs Macro when a cell value is changed
    By gordonf35 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-25-2012, 06:07 PM
  3. Can you exclude coloums from a macro that runs automatically?
    By snoopy1461 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-31-2011, 09:37 AM
  4. Macro automatically runs report
    By yes sir in forum Access Tables & Databases
    Replies: 9
    Last Post: 08-26-2010, 04:15 PM
  5. Macro that runs automatically?
    By Johann in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-01-2006, 09:20 AM

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