+ Reply to Thread
Results 1 to 6 of 6

Unexplainable (to now) error when trying to draw borders

  1. #1
    Registered User
    Join Date
    09-10-2010
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    17

    Unexplainable (to now) error when trying to draw borders

    Hello,

    As part of a large VBA Excel program, I am trying to format some cells by drawing a thick border around range of cells.

    The code below works for the first half and bugs for the second half. Indexes are not in question, Excel debugger shows the first .LineStyle = xlContinuous after the second range set.

    Does anyone have an explanation why this might be so?

    As far as I am concerned, I have a hard time making any difference between the first set of borders and the second.

    Please Login or Register  to view this content.


    Any help will be much appreciated.

    Thank you in advance
    Last edited by NiceLittleRabbit; 12-15-2010 at 10:24 AM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Unexplainable (to now) error when trying to draw borders

    shorter option:
    Please Login or Register  to view this content.
    Last edited by watersev; 12-15-2010 at 09:50 AM.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,440

    Re: Unexplainable (to now) error when trying to draw borders

    I suspect it has more to do with how you are assigning the range than what you are doing with it.

    After you have set the second range, check what its address is in the immediate window.

    ?rng.address

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Unexplainable (to now) error when trying to draw borders

    Try:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  5. #5
    Registered User
    Join Date
    09-10-2010
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Unexplainable (to now) error when trying to draw borders

    Quote Originally Posted by watersev View Post
    shorter option:
    Please Login or Register  to view this content.
    I had already tried this, but it produces all the borders (of all cells within the range) to have thick borders, whereas I only want a think border around the range.

    However, Excel accepts your code and rejects (sometimes) mine.

    Here's the code rewritten so that anyone can check it out


    Please Login or Register  to view this content.
    As you have guessed, my objective is first to have a good working code, and second to understand why my code did not work ;-)

    Thanks for your time in answering and I am looking forward to the next post

  6. #6
    Registered User
    Join Date
    09-10-2010
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Unexplainable (to now) error when trying to draw borders

    It works!!!

    Thank you romperstomper, watersev and TMShucks for your time and answers

    To TMShucks, I think the second code I posted with fixed cells discards the option that the range has not been correctly assigned

    I still do not know why it did not work, but I am happy

    Thank you all

+ 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