+ Reply to Thread
Results 1 to 8 of 8

Run macro for entire column instead of one cell

  1. #1
    Registered User
    Join Date
    07-05-2022
    Location
    Kentucky
    MS-Off Ver
    Office 365
    Posts
    3

    Run macro for entire column instead of one cell

    First let me say that I am not a programmer or Excel power user. I did not write the following macro, I pulled it off the internet (possibly from here I don't know). I wish I could cite the author but I can't. I just wanted to make it clear I am not taking credit for this macro. What I want to do is run the macro in an entire column as opposed to a single cell. So for example where the macro targets "D3" I want the macro to run in the entire "D" column from "D1" to infinity basically.

    Also as a side note (and separate coding) can you show me how I can run this macro targeting say just cell "A1" and all of the "D" column.

    Thanks for any help.
    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 07-05-2022 at 10:55 AM.

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

    Re: Please help me alter this macro

    Welcome to the Forum Psyclops!

    You have violated two rules in your first post. I have fixed them because you are new. Please take the time to review our rules. There aren't many, and they are all important.

    Moderator's note: Rule #1 requires good titles. I have updated it for you this time because you are a new member. --6StringJazzer

    Moderator's note: Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2503
    Posts
    1,485

    Re: Run macro for entire column instead of one cell

    For just column D:
    Please Login or Register  to view this content.
    Adding more ranges to the mix:
    Please Login or Register  to view this content.
    If things don't change they stay the same

  4. #4
    Registered User
    Join Date
    07-05-2022
    Location
    Kentucky
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Please help me alter this macro

    Understood, and I apologize for the violations.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,163

    Re: Run macro for entire column instead of one cell

    Quote Originally Posted by Psyclops View Post
    targeting say just cell "A1" and all of the "D" column.
    You mean all of D, as I just showed, plus also allow A1? But you can't add another Worksheet_Change sub to the same module. Please explain the big picture and what you are trying to do with this second version.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-05-2022
    Location
    Kentucky
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Run macro for entire column instead of one cell

    I want each cell in a column (example "D" column) to keep a running total of numbers added in each cell, independent of the other cells in the column. Not cumulative down the column. So for example I put "3" in D5 then I add "3" to D5 then the total of D5 displays "6" then say I add "3" and the total displays "9" but I want each cell in column "D" to do this independently so if I put "6" in D1 it doesn't alter the total in D5 etc. I don't know if that makes sense and if it does I don't know if its even possible in Excel. Then I would like other cells I designate to do the same like A1 and C3, etc. Not column A and Column C but just cells A1 and C3. I can live with just running in a column if I can't also designate single cells to also run it.

    Here is the big picture if it helps. I'm trying to make a sheet to track consumable items for a game I play.

    So lets say on the sheet on "Row 1" (cells "A1 through C1" I write "Handgun bullets" then in "D1" I put "10" to represent I have 10 on hand. Then say I shoot 3 bullets so I go to D1 and input "-3" so the total of "D1" now shows 7 bullets left. But say I find 6 bullets later, I go to "D1" and input 6 so the total of "D1" updates to 13.

    Then on "Row 2" (cells "A2 through C2") I write "Rifle Bullets" and in "D2" I put "20" to represent 20 on hand. Then say I shoot 5 so I go to "D2" and input "-5" and the total in "D2" updates to 15.

    Then "Row 3" (cells "A3 through C3") I write "Hand grenades", etc etc etc.

    So I don't want data I enter in "D1" to alter or be altered by data I put in say "D3"

    I guess if I can get this far I'll be happy.

    The reason I also wanted to target individual cells along with "column D" was so I can track other items here and there on the sheet without affecting a "whole" column or row.

    Thanks for any help and I apologize if there should have been code tags in any of this.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,163

    Re: Run macro for entire column instead of one cell

    We're going to need your file for this. See yellow banner at the top of the page.

  8. #8
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,675

    Re: Run macro for entire column instead of one cell

    It seems you want to fire a cell change, save the old value (before change), then add up with new value (after change)
    HTML Code: 
    Quang PT

+ 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] Is it possible to alter code from another macro
    By bdouglas1011 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-14-2019, 12:21 AM
  2. Alter value in macro
    By Orum in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-14-2014, 12:22 AM
  3. Alter value in one cell alter value in multiple cells
    By Bryan Noqw in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 03-11-2008, 05:31 AM
  4. macro to alter a formula
    By Crispy1974 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-21-2007, 10:42 AM
  5. How can I alter this Macro?
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2006, 12:10 PM
  6. [SOLVED] How can I alter this Macro?
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-09-2006, 05:15 AM
  7. [SOLVED] how to alter the date within a macro
    By LWhite in forum Excel General
    Replies: 2
    Last Post: 01-04-2005, 11:06 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