+ Reply to Thread
Results 1 to 14 of 14

Macro to apply borders to all cells with text

  1. #1
    Registered User
    Join Date
    01-22-2009
    Location
    Okinawa, Japan
    MS-Off Ver
    Excel 2003
    Posts
    5

    Macro to apply borders to all cells with text

    I have been looking everywhere for an example on how to apply+ borders to all cells in a worksheet with text.

    I pull reports from a program and sometimes there are blank cells throughout the row. Currently I have to manually highlight all cells with text and press the border button. It would save a lot of time if I could just run a macro that would put borders around all cells that have text.

    Is this possible?

    Thank you!
    Last edited by VBA Noob; 01-22-2009 at 01:57 PM.

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    This will put borders around each individual cell that has text. Is that what you are looking for?

    Please Login or Register  to view this content.
    HTH

    Jason

  3. #3
    Registered User
    Join Date
    01-22-2009
    Location
    Okinawa, Japan
    MS-Off Ver
    Excel 2003
    Posts
    5

    Question 50% Solution

    Jason,

    Thanks for the quick reply. When I ran the macro it formatted every cell from left to right that had text in that row.

    Here is an example of the spreadsheet I have:

    Text are in the following cells:

    A1 B1 C1 D1
    D2
    B3 D3

    I am just looking for those cells to receive the borders. I do not want borders in the others (i.e.A2, A3, B2)

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Can you post up an example copy of your workbook so I can take a look at it?

  5. #5
    Registered User
    Join Date
    01-22-2009
    Location
    Okinawa, Japan
    MS-Off Ver
    Excel 2003
    Posts
    5

    Example

    Here is an example of the worksheet after I format it.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Ok, so in your example, what did you expect to accomplish? Do you want borders only in cells that have letters? Or only that have words? Please be more specific in exactly what you are looking for.

  7. #7
    Registered User
    Join Date
    01-22-2009
    Location
    Okinawa, Japan
    MS-Off Ver
    Excel 2003
    Posts
    5
    I need the macro to put borders around all cells with text inside. Just like how I have the borders formatted in the sample worksheet I sent you. If the cell does not have text, it does not get a border. If it has text it gets a border.

  8. #8
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    The issue is that several of the cells have spaces in them. So you first need to get rid of those, then apply the borders. Try:

    Please Login or Register  to view this content.
    HTH

    Jason

  9. #9
    Registered User
    Join Date
    01-22-2009
    Location
    Okinawa, Japan
    MS-Off Ver
    Excel 2003
    Posts
    5

    Thumbs up Solved

    Thanks for the help. You saved me a lot of time.

  10. #10
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Solved

    Hello Jason,

    The macro provided by you is very good. I'm using it and it works really great.
    The only thing I can't get it doing is to also put border around some cells that have a number in it.
    I have some data that has at the end a total and to the right the amount (number). The
    rest all get the border but it skips the cell with the number. Is there a way to make it also put it arround the number?
    (I did add a comma and then xlNumbers, it does not do the trick).

    Again thanks for the great MACRO ;-)

  11. #11
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Macro to apply borders to all cells with text

    Hello Megatronixs, and welcome to the forum.

    Unfortunately you have inadvertently broken one of the forum rules. Please read the following and make the necessary change. Thanks.

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

  12. #12
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Macro to apply borders to all cells with text

    Hello Cutter,

    Thanks for informing me about this. I will avoid this in the future.

    greetings.

  13. #13
    Registered User
    Join Date
    06-10-2013
    Location
    ntaineN was
    MS-Off Ver
    Excel 2007
    Posts
    4

    Red face Re: Macro to apply borders to all cells with text

    Hi,

    Can you please help me make a macro to add border.

    See attached for example. Thanks
    Attached Files Attached Files

  14. #14
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro to apply borders to all cells with text

    Jersey_01,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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