+ Reply to Thread
Results 1 to 7 of 7

Why is my cell format changing after code execution?

  1. #1
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Why is my cell format changing after code execution?

    I have an application that I am completing; however each time i think i am done my testing reveals something else. My issue here is whenever I get a runtime error my cell format changes, it even change the cell format if I delete multiple cells at once. It my first VBA program so i guess its not the best written program, but so far it does what i want. I just have this issue annoying me at this time.

    Can anyone please look at the code and share a view or two? Thanks.


    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Why is my cell format changing after code execution?

    I can't see anything in that code that would change the format.

    How exactly is it changing?

    What is the code meant to do?

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Why is my cell format changing after code execution?

    Clear clears both the cell content and formatting -- use ClearContents. Also, you should test if more than one cell is affected. Untested:

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Re: Why is my cell format changing after code execution?

    thank you both so much for looking at my code; I will try what shg says and report my result tomorrow.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Why is my cell format changing after code execution?

    BTW, why are you using a different RegEx pattern for the first test?

  6. #6
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Re: Why is my cell format changing after code execution?

    because each area has adifferent validation, one exclues the C while the other includes the C. I am not as good as you guys are so I know the prgram may not have been written with much effeciency, but i am learning from you guys as i go along.

  7. #7
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Re: Why is my cell format changing after code execution?

    Ok shg, your suggestion worked, thank you so much.

    Quote Originally Posted by shg View Post
    Clear clears both the cell content and formatting -- use ClearContents. Also, you should test if more than one cell is affected. Untested:

    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