+ Reply to Thread
Results 1 to 4 of 4

Column stripped of formatting when running macro

  1. #1
    Registered User
    Join Date
    02-27-2018
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2016
    Posts
    4

    Column stripped of formatting when running macro

    I'm relatively new to VBA and am struggling to find a solution to this problem. I hope someone can help me out

    I have a set of functions that are called to produce a user-defined report.
    When running any of those report-building functions, the formatting is stripped from a range of cells in the ActiveSheet when I run it without breaks (see attached image showing cells without formatting)
    FormattingStripped.JPG

    It doesn't matter which sheet is active at the time, the formatting will be stripped in range("G9:G48") or range("F9:F48").
    There are no references to this range in my script, and no references to "ActiveSheet".

    The format stripping occurs at some point within the below section of code, but as mentioned previously, does not occur when I add breaks in.
    I've tried commenting sections out to narrow it down to a specific part, but it doesn't seem to make any difference...

    Please Login or Register  to view this content.

    Has anyone else seen this before?
    I'm totally lost on this one, would appreciate any insight

    Thanks!

  2. #2
    Registered User
    Join Date
    02-27-2018
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2016
    Posts
    4

    Re: Column stripped of formatting when running macro

    Anyone got any ideas on this one?
    I've spent like a week trying to resolve this to no avail, and my presentation of this reporting system is in 4 days

    Thanks very much in advance for any guidance provided

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Column stripped of formatting when running macro

    Hi ettedo,

    Whey you say it works ok when you step through the code but fails when you run it, it might be a timing problem. The idea is that the VBA is sending code before other things are done. To set "wait" points in your code you might insert some DoEvents in your code. This then allows the OS to finish before coming back and trying to throw more VBA.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    02-27-2018
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2016
    Posts
    4

    Re: Column stripped of formatting when running macro

    Hey MarvinP

    Thanks for your quick response
    That definitely makes sense... I had made the incorrect assumption that each event only begins after the previous event has completed
    I'll read up on 'DoEvents' and will insert it after the more time consuming events at the beginning of my code.

    I actually just wrote in a band-aid fix after my previous post/desperate-plea (see code below), whereby the report template formatting is painted over to the completed report. It works, but obviously adds to the run time which is not ideal.
    Hopefully adding in some 'DoEvents' will mean I can remove the dirty fix :D


    Please Login or Register  to view this content.

    Thanks for helping a gal out, I'll post the result later today

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 06-22-2017, 06:56 AM
  2. [SOLVED] Formatting sheets with macro running very slowly
    By nickmax1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-21-2012, 10:04 AM
  3. Formatting Changes after running macro.
    By jakeisbill in forum Excel General
    Replies: 1
    Last Post: 07-02-2012, 11:07 AM
  4. Vba conditional formatting macro partial running
    By OzNoz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-20-2011, 03:17 AM
  5. Pivot Table graph looses formatting after running formatting macro
    By arthurbr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-27-2011, 04:16 AM

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