+ Reply to Thread
Results 1 to 7 of 7

Run macro in different cell than recorded

  1. #1
    Registered User
    Join Date
    04-15-2018
    Location
    MI
    MS-Off Ver
    2016
    Posts
    7

    Run macro in different cell than recorded

    Hello All,

    I have a worksheet that has multiple options for us to highlight. I have recorded a macro to change the fill to black, bold the font and change it white. How Do i now change this code to work on any of the cells (all merged) I please.

    Please Login or Register  to view this content.
    I will end up making a macro to revert back to original format once the option i need highlighted on my worksheet is no longer needed.

    I would like to in the end add a cmd button to my context menu in the end.

    Appreciate the assistance from you all!

    -A
    Last edited by Moomoo327; 04-15-2018 at 09:38 AM.

  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
    48,494

    Re: Run macro in different cell than recorded

    Take this line out.

    Please Login or Register  to view this content.
    Then it will work with whatever cells are selected when you run the macro.
    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
    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
    48,494

    Re: Run macro in different cell than recorded

    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.

    Click on Edit to open your thread, then 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

  4. #4
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,494

    Re: Run macro in different cell than recorded

    Next to the suggestion of TMS so that you can apply your formatting to any range you select yourself.
    You should also look at the code for settings that are recorded but do not need changing.

    I shortend your macro by only leaving in the most essential options you changed.
    Recording a macro is a good way to record what you want but it also gives a lot of redundant code
    removing things you do not need to change helps prevent unexpected result and it also helps you to understand the code


    Please Login or Register  to view this content.
    Last edited by Roel Jongman; 04-15-2018 at 10:47 AM.

  5. #5
    Registered User
    Join Date
    04-15-2018
    Location
    MI
    MS-Off Ver
    2016
    Posts
    7

    Re: Run macro in different cell than recorded

    Thats awesome! Thank you for the comments in there as well.

    Please Login or Register  to view this content.

    Is that code up there simplified from below?


    Please Login or Register  to view this content.
    I am trying to add a Black_Fill and Clear button to my context menu but I keep adding buttons everything i open and close the WB.

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

    I thought I knew what i was doing..

    -A

  6. #6
    Registered User
    Join Date
    04-15-2018
    Location
    MI
    MS-Off Ver
    2016
    Posts
    7

    Re: Run macro in different cell than recorded

    and this
    Please Login or Register  to view this content.
    Does not seem to be working for some reason

  7. #7
    Registered User
    Join Date
    04-15-2018
    Location
    MI
    MS-Off Ver
    2016
    Posts
    7

    Re: Run macro in different cell than recorded

    Quote Originally Posted by Moomoo327 View Post
    and this
    Please Login or Register  to view this content.
    Does not seem to be working for some reason
    Okay so this only works when not in Page Break Preview mode? lol

+ 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] Recorded Pivot Table Macro Doesn't Do What I Recorded!
    By diakonos1984 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-26-2013, 11:01 AM
  2. [SOLVED] How to run a recorded macro when cell values change?
    By Clue_Less in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-15-2012, 12:01 PM
  3. Run pre recorded macro from any selected cell
    By Si902 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 10-26-2011, 03:43 PM
  4. Cursor Needs in Same Cell in Recorded Macro
    By tariqnaz2005 in forum Excel General
    Replies: 7
    Last Post: 02-09-2010, 06:28 AM
  5. Macro that splits any cell not just the one recorded with the same numbers
    By emj08 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-19-2008, 06:11 AM
  6. Recorded macro has hard cell contents.
    By DocBrown in forum Excel General
    Replies: 4
    Last Post: 08-11-2006, 02:20 PM
  7. Excel macro, editing recorded cell.. not current
    By TroyT in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-12-2006, 09:30 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