+ Reply to Thread
Results 1 to 6 of 6

Use of Range and Last row to add borders around cells.

  1. #1
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Use of Range and Last row to add borders around cells.

    After searching and reading some other posts similar to what I'm looking to do, I have decided that I could use a little help.

    The code I have right now that does not work is...
    Please Login or Register  to view this content.
    What I'm doing to taking a report that is supply in a Word Document and analyzing it in Excel. The macro I have created removes columns that are not needed and inserts a few new ones. The sheet has columns from A:H and I would like to have borders around all cells both empty and with content. However, every time I need to do this the row count will change. I feel that I'm on the right track, but not sure what corrections I need to make for it to work.

    BTW... there is no hurry on this as I'm leaving the office soon and will not return until Monday.

    Thanks in advance.

    Brian
    Last edited by BBoydAnchor; 05-21-2012 at 03:06 PM. Reason: Solved

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Use of Range and Last row to add borders around cells.

    I tested you code snippet and it works fine.

    What kind of problem do you have with it? Do you get any error messages? Or do you want to get rid of "old" borders before you write new data to range A1:H & LastRow.

    If this is the case you could just add

    Please Login or Register  to view this content.
    to get rid of "old" borders.

    Alf

  3. #3
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use of Range and Last row to add borders around cells.

    I get a run-time error '1004': Method 'Range' of object '_Global' failed. Below is all the code. It was created as one would normally do by recording the steps and then I modified the code the best I knew how. There may even be some code that could be removed or modified to be more efficient.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Use of Range and Last row to add borders around cells.

    You could try to change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    and also change
    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    Alf
    Last edited by Alf; 05-21-2012 at 01:56 PM.

  5. #5
    Registered User
    Join Date
    12-15-2011
    Location
    Charleston, SC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Use of Range and Last row to add borders around cells.

    Thank you Alf. This works perfectly.

  6. #6
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,784

    Re: Use of Range and Last row to add borders around cells.

    Glad to be of help.

    Alf

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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