+ Reply to Thread
Results 1 to 10 of 10

Add Border if Cell is Not Blank

  1. #1
    Registered User
    Join Date
    10-09-2012
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2020
    Posts
    45

    Add Border if Cell is Not Blank

    Hi everyone,

    I have gotten some great help here recently and am looking for a few tidbits more...

    I have a workbook with 10+ sheets and have a lot of VBA running those sheets. One thing I'd like to add is borders to the dynamic range of cells that I have. All my data across the sheets start in row 22 and the following columns have data: B:G, J:O, Q:U and W:AC. Any help to add full borders around those cells to make it easier to read would be greatly appreciated. Thanks!

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Add Border if Cell is Not Blank

    Please Login or Register  to view this content.
    That's a future version ???

    P.s. I can't help you with your VBA problem.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    10-09-2012
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2020
    Posts
    45

    Re: Add Border if Cell is Not Blank

    Yes! I realized I messed up typing in 2010, but thought it was funny, soooooo 2020 it is!

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: Add Border if Cell is Not Blank

    Try:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-09-2012
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2020
    Posts
    45

    Re: Add Border if Cell is Not Blank

    Thanks, @Mumps1. That is close, but not quite right. It adds borders to cells above row 22 and also does not add a border to blank cells in the range that I would like.

    I messed up on the title of the thread before I realized how it wasn't quite right. I have my data starting in cell B22 and is in columns B:G, J:O, Q:U and W:AC. I can't make it be non-blank cells as occasionally cells in that range may be blank, but I'd like the whole row to have a border around it.

    I have a few VBA scripts that run and thought I could attach the code for the border inside those scripts, but I'm not quite sure how to add that. I have added an example of my code below...

    Please Login or Register  to view this content.
    Basically, it copies data from one sheet to another if it meets a certain criteria. I'd like to just add some border styling to the script itself if possible. Thanks!

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: Add Border if Cell is Not Blank

    I'm not sure how you decide which rows you want highlighted. Do you want want to highlight the rows that have no data in them? Maybe if you could attach your file it would be easier to understand.

  7. #7
    Registered User
    Join Date
    10-09-2012
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2020
    Posts
    45

    Re: Add Border if Cell is Not Blank

    Sorry, I'm posting from my personal computer (as I'm off today), so I'm going to have to try to explain it the best I can and if not, will post a sample tomorrow. The only way I had that Excel formula was a previous post I had on this forum.

    I have VBA scripts that run to populate data in columns B:G, J:O, Q:U and W:AC. Each section of columns (B:G, J:O, Q:U and W:AC) have data populated to them by a different VBA script for each column grouping (i.e. B:G has it's own script, J:O has its own, etc.). The amount of rows in each section of columns varies - some have 10, while others have 300+. I'd like to add a border to each cell that the VBA script(s) add. Even though a few cells here and there may be blank, I'd still like it to have a border around it.

    So my thought is, I need to add border formatting to my original scripts, which is why I posted a version of one above. I'm not too hot at VBA, so am just trying to tweak existing code that I have found online. Thanks for all the help thus far!

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: Add Border if Cell is Not Blank

    Would I be correct then, that you want each range in each column (including blank cells) highlighted? For example, if columns B:G have data up to row 10, then the range B1:G10 would have a border around it. If columns J:O have data to row 300, then the range J1:O100" would have a border around it and the same for the other columns.

  9. #9
    Registered User
    Join Date
    10-09-2012
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2020
    Posts
    45

    Re: Add Border if Cell is Not Blank

    Yes, that's exactly correct!

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: Add Border if Cell is Not Blank

    Try:

    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)

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