+ Reply to Thread
Results 1 to 4 of 4

Add Formatting to Last Row of Table via VBA

  1. #1
    Registered User
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    2007
    Posts
    93

    Add Formatting to Last Row of Table via VBA

    I have a macro that will create a report. It will overwrite old data and generate a new report each time the macro is run. Since the data length is not consistent, I'm trying to use relative references but struggling with adding a border on the last row of data (the formating gets wiped when I erase the old data).

    Basically, I need cells B3:K[LastRow] to have a bottom border. Unfortunately, with the code below, if there is an empty cell in the first row of data, the XLToRight function stops at the open cell and doesn't go all the way to Column K. Column B will always have data in it, so XLDown works no problem.


    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,534

    Re: Add Formatting to Last Row of Table via VBA

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 04-30-2020 at 07:45 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    12-09-2015
    Location
    Virginia, USA
    MS-Off Ver
    2007
    Posts
    93

    Re: Add Formatting to Last Row of Table via VBA

    You're the man! Thank you!

    I'm about to start a new thread about creating a "double column" report. I have 5 fields in the "first column" of the page and the same five fields in the 2nd column of the report. So columns A:F are "Column 1", column G is a divider cell, and columns H:M are "Column 2".

    I'd like to fill all of column 1 data before moving over to column two starting from Cell A4 and moving through to row 35. Instead of moving to row 36, the data (from another sheet), would continue filling in from the top of Column 2 in Cell H4 all the way throuh M35.

    Finally, the data resumes populating Column 1 (on page 2) back at Cell A36 and continues that trend until all of the data is reported.

    Any ideas on the best way to go about this?

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,534

    Re: Add Formatting to Last Row of Table via VBA

    You're spot on. Starting a new thread is the best way to go about it.

+ 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. Replies: 2
    Last Post: 11-16-2019, 05:01 AM
  2. Replies: 6
    Last Post: 12-01-2017, 03:45 PM
  3. Replies: 1
    Last Post: 12-08-2016, 03:14 PM
  4. Replies: 9
    Last Post: 03-07-2016, 10:39 AM
  5. Replies: 0
    Last Post: 09-12-2013, 05:21 AM
  6. Pivot Table graph looses formatting after running formatting macro
    By arthurbr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-27-2011, 04:16 AM
  7. [SOLVED] retain table formatting when writing excel table to a txt file
    By deanop in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-03-2005, 01:05 AM

Tags for this Thread

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