+ Reply to Thread
Results 1 to 11 of 11

How to make a singular macro apply to multiple cells?

  1. #1
    Registered User
    Join Date
    11-10-2014
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    38

    How to make a singular macro apply to multiple cells?

    I have a range of cells where I would like a tick to appear when I type anything in the cell.

    At the moment I have the following macro which works:

    Please Login or Register  to view this content.

    With this macro if I type anything other than "0" in cell B2, the value in cell B2 will change to a tick.

    I would like to apply this macro to multiple cells, e.g. if I type anything in cell D5 I want cell D5 to change to a tick. if I type anything in cell F13 I want cell F13 to change to a tick. Etc

    I understand that I could just copy the macro over and over again and change each cell value but that would be time consuming.

    I am wondering if I can change the target address and the target value to cell "n" so that any change in a cell will only result in a tick appearing in that particular cell.

    Also just thought I'd add that the cells I would like to apply my macro to range from B2 till I18
    Last edited by Lowa; 11-10-2014 at 06:43 PM. Reason: Additional Information

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: How to make a singular macro apply to multiple cells?

    Please use Code Tags


    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: How to make a singular macro apply to multiple cells?

    You can try by adding or method in IF condition

    Please Login or Register  to view this content.
    Thanks - Naveed
    -----------------------------
    If the suggestion helps you, then Click * to Add Reputation
    To Attach File: Go Advanced>>Manage Attachments>>Add Files (In Top Right Corner)>>SelectFiles>>.........Locate Your File(s)>>Upload Files>>Done (In Bottom Right)
    1. Use [code] code tags [\code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    2. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: How to make a singular macro apply to multiple cells?

    Hi,

    If you want to apply this on specific cells only (not whole sheet's cells), then define a range and use intersection() :

    Please Login or Register  to view this content.
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: How to make a singular macro apply to multiple cells?

    Please note that, if you want a Worksheet Change event handler to make changes to the worksheet, you must use Application.EnableEvents = False before making the change(s) and Application.EnableEvents = True after, or the event handler could be executed more than once and even loop.

    That applies regardless of whether you want to apply the event handler to a single cell, several or many specific cells, or all cells on the worksheet.

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

    Regards, TMS

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: How to make a singular macro apply to multiple cells?

    Not a good idea to go back and add detail to the original post. It can easily get overlooked ... and it can make nonsense out of replies you have already had.

    BUT ... please add Code Tags to your code excerpt in your original post (see below).

    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



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  7. #7
    Registered User
    Join Date
    11-10-2014
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    38

    Re: How to make a singular macro apply to multiple cells?

    Thanks for your Help guys, TMS's code worked

  8. #8
    Registered User
    Join Date
    11-10-2014
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    38

    Re: How to make a singular macro apply to multiple cells?

    Also i'm new to this forum, this was actually my first post and i'm still learning the rules so I have another question: when my thread is solved should I note which reply solved my question? if so, how do I do this?

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: How to make a singular macro apply to multiple cells?

    You're welcome. Thanks for the rep.

    Thanks for editing the first post and adding code tags.

    when my thread is solved should I note which reply solved my question?
    No, there's no specific way to acknowledge which post(s) resolved your issue (in this forum).

    You can mark the thread solved, as you have, and you can give positive rep to the contributor(s), as you have, but there's no "best answer" or "best solution" option. And, of course, you can acknowledge, in the thread, which solution you opted to go with, as you have

    Not a bad first thread, all in all.

    Regards, TMS

  10. #10
    Registered User
    Join Date
    11-10-2014
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    38

    Re: How to make a singular macro apply to multiple cells?

    No Worries, thanks again for the help

  11. #11
    Registered User
    Join Date
    09-18-2015
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    4

    Re: How to make a singular macro apply to multiple cells?

    Hey guys,
    I have a similar problem to the above though the code is very different. Right now the code just applies the macro to a singular cell B3 and I am hoping to apply it to any cell on the sheet that I click on. I have pasted the code below if you guys could kindly take a look:


    Please Login or Register  to view this content.
    Last edited by surya316; 09-18-2015 at 11:00 AM.

+ 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. Macro to make multiple cells mandatory - Excel 2007
    By dupes420 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-15-2014, 05:38 AM
  2. Trying to make this Macro Apply to Every Populated Row??
    By Conoonor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-11-2014, 10:35 PM
  3. [SOLVED] Using macro to apply mathematical formula to multiple cells at once... quick help needed!
    By akrhodes in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-15-2014, 09:30 AM
  4. Excel Data Validation - Select Multiple Items - Need to Apply Macro to Multiple Rows
    By kristynroll in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-30-2012, 07:44 PM
  5. Linking several cells from 1 sheet to another using a singular reference
    By chrispygreen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2011, 04:31 PM

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