+ Reply to Thread
Results 1 to 8 of 8

Adding to a macro recording

  1. #1
    Forum Contributor
    Join Date
    03-05-2015
    Location
    Playa Del Carmen, Mexico
    MS-Off Ver
    2016
    Posts
    111

    Adding to a macro recording

    Attached you will find two files.

    Generator4.0 is a blank file that I will paste a report into and then run the macro using Ctrl+Shift+C.

    ForumExample is the before and after results of my macro recording attempt

    But.....

    I forgot to center columns B,C,D,F,G,H,I,K,L & M at the end of the report. What code is required to do so?


    The following is desirable, but far beyond my skill set.......


    1. Is it possible to add 'All Borders' to just the remaining data?

    2. Is it possible to add the fill color to black and the font color to white for all dates in Column G for the date before the day I run the report?

    3. Is it possible to add the fill color to black and the font color to white for all dates in Column H for the dates three days from the day I run the report?


    Thank you in advance.
    Attached Files Attached Files

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,650

    Re: Adding to a macro recording

    Add such code just before the final End Sub

    Please Login or Register  to view this content.
    I also started cleaning a bit earlier code, but have to log out now so it is only partially cleaned. Basically, you can remove all sequences like

    Please Login or Register  to view this content.
    if the next line is
    Please Login or Register  to view this content.
    also all
    Please Login or Register  to view this content.
    such lines can be deleted
    Attached Files Attached Files
    Best Regards,

    Kaper

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Adding to a macro recording

    I was tidying up the code before adding the new functionality but as Kasper has kindly sorted that bit for you I've just added their code to my rewrite below.

    See attached.

    Please Login or Register  to view this content.
    BSB
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    03-05-2015
    Location
    Playa Del Carmen, Mexico
    MS-Off Ver
    2016
    Posts
    111

    Re: Adding to a macro recording

    This is amazing. Thank you. It feels wrong that I'm getting this for free. Can I pay this back somehow?


    I think my request below was wrong.

    '3. Is it possible to add the fill color to black and the font color to white for all dates in Column H for the dates three days from the day I run the report?'


    I am looking for the fill in column H to be for only the 3rd day after the report is run (and now I think about it - the 4th also).

    In fact, I would like the two days after I run the report to be filled in grey.

    Is this something you can do ?

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,650

    Re: Adding to a macro recording

    It is this last part of the code, which is responsible for coloring cells. I used conditional formatting for this.
    So instead of:
    Please Login or Register  to view this content.
    You could use for instance (I am not sure if I understand well the requirement. It is now formatted that only tomorrow (today+1) and the day after (+2) in gray and day +3 and +4 in black:

    Please Login or Register  to view this content.
    or may be black for days +3 and +4 and gray for days in the past , today, tomorrow and the day after tomorrow version:

    Please Login or Register  to view this content.

    As for posiible "paying back": Well, on the public part of the forum we (hope BadlySpelledBuoy would agree) do it mostly just for fun, or to test ourselves, or to train/keep our skills form rusting :-)

    There is also a "commercial services" part - see the menu bar in the forum header and FAQ here: https://www.excelforum.com/the-water...-services.html

    But unfortunately , BadlySpelledBuoy could not answer there (it's limited to forum admins, moderators and gurus).

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Adding to a macro recording

    Quote Originally Posted by Kaper View Post
    As for posiible "paying back": Well, on the public part of the forum we (hope BadlySpelledBuoy would agree) do it mostly just for fun, or to test ourselves, or to train/keep our skills form rusting :-)
    Wholehearted agree. I do it for fun and to help others. "Playing with Excel" is my day job and helping others on here often forces me to think of solutions for problems that I wouldn't usually encounter.

    BSB

  7. #7
    Forum Contributor
    Join Date
    03-05-2015
    Location
    Playa Del Carmen, Mexico
    MS-Off Ver
    2016
    Posts
    111

    Re: Adding to a macro recording

    In hindsight, I see I did not make myself clear.

    Today is the 2nd December.

    I am looking for a black fill with white text in column G for the day before the report is run. (1st December)

    And the same in Column H, 3 & 4 days from now (5th & 6th December)

    And if possible - to throw one more thing in there - a medium grey fill for tomorrow (3rd) and the next day (4th)

    (I have to say - I also enjoy excel as a hobby, helping my colleagues - like I am with this - and wish I could code like you both.) Thank you.

  8. #8
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,650

    Re: Adding to a macro recording

    Try replacing part for column G with:
    Please Login or Register  to view this content.
    and for column H:
    Please Login or Register  to view this content.

+ 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. Help adding text to a column during a marco recording
    By Ayupchap in forum Excel General
    Replies: 3
    Last Post: 09-17-2021, 07:26 PM
  2. Problem with recording a macro with long formula - works in Excel but not in macro
    By tonybeo2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-28-2015, 11:25 AM
  3. Session Recording (Login info recording)
    By cvishu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2014, 04:10 PM
  4. recording a macro
    By srinivastsc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-22-2013, 04:28 PM
  5. Recording cell changes and adding rows
    By aznprod517 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-28-2009, 12:59 PM
  6. [SOLVED] How do I make the Stop Recording bar pop up when recording macros
    By J in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-10-2006, 04:50 PM
  7. Recording Macro
    By Connie Martin in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-25-2005, 01:45 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