+ Reply to Thread
Results 1 to 4 of 4

Switching borders

  1. #1
    Registered User
    Join Date
    04-29-2006
    Posts
    12

    Switching borders

    Hi,

    I need to switch the right and left borders in cells, and I'm not finding a good solution. The user will have various styles of borders per cell. Sometimes a cell might have a thick border on it's left while having a thin border on it's right. Sometimes they might have a thin border on the left, and no border on the right. I will need to switch the border styles to opposite sides.

    I've been experimenting with this:


    Please Login or Register  to view this content.
    But I'm finding that if one (or both) sides doesn't have a border, then the code is adding a thin border. For example, if I have a cell that originally has a thick border on the left, and no border on the right - after I run the code it does put the thick border on the right, but a thin border has been placed on the left!

    My only other question is, is there more data I need to check for besides just linestyle, weight, and colorindex?

    Thanks for looking at my questions. I'm working with Excel 14.1.4 on the Mac (10.7).

    Jay

  2. #2
    Registered User
    Join Date
    04-29-2006
    Posts
    12

    Re: Switching borders

    After working with this for awhile, I think I realized that when I'm trying to set the weight of a border, it automatically sets one, whether I want it or not. So if I first check if there's no border, I can set it accordingling:

    Please Login or Register  to view this content.
    Jay

  3. #3
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Switching borders

    Jay, your code is ok. If you do this slight change it will work exactly as you want:

    Please Login or Register  to view this content.
    Here comes the explanation. Even when a cell has no border, it does have weight and color by default, generally a thin black line. So when you set the propertys of the cell to that, the border appears, even when the linestyle was set to show nothing. This is beacause there is a difference between it being a default setting and you setting it, even when it's done in code. So if you do set the weight and colorindex and set the linestyle after those, this won't be a problem. At least on my computer it isn't lol, works ok with that little change.
    I hope that helps.
    .?*??)
    `?.???.?*??)?.?*?)
    (?.?? (?.?
    Pichingualas <---
    ??????????????????????????

    Wrap your code with CODE TAGS.
    Thank those who helped you, Don't forget to add to their REPUTATION!!! (click on the star below their post).
    Please mark your threads as [SOLVED] when they are (Thread Tools->Mark thread as Solved).

  4. #4
    Registered User
    Join Date
    04-29-2006
    Posts
    12

    Re: Switching borders

    Quote Originally Posted by Pichingualas View Post
    Jay, your code is ok. If you do this slight change it will work exactly as you want:

    Please Login or Register  to view this content.
    Hi Pichingualas,

    Thank you very much for your reply. It might be a small change, but it makes a big difference! I appreciate your explanation and code. Thanks again! :-)

    Jay

+ 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