+ Reply to Thread
Results 1 to 9 of 9

Clean the UsedRange

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Clean the UsedRange

    I have a macro that I use to clean my used range, but it's slow, and I notice my mouse is flickering while it runs. I'd appreciate any help I can get in trouble-shooting it:
    Please Login or Register  to view this content.
    Last edited by jomili; 12-30-2011 at 12:53 PM.

  2. #2
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Clean the UsedRange

    What does your CleanString function look like?

    Here is how I would do the above code:
    Please Login or Register  to view this content.

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

    Re: Clean the UsedRange

    hi jomili, two questions:
    1. Why do you use Select in your code?
    2. The flickering comes from looping the cells I guess. You could possibly try to use Specialcells (data volume is unknown)

  4. #4
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Clean the UsedRange

    You could also try this:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Clean the UsedRange

    Or
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Re: Clean the UsedRange

    Roy,
    I was working on the same lines as you, prompted by Watersev's suggestion. Here's my crude attempt:
    Please Login or Register  to view this content.
    Yours looks a lot cleaner. Why did you use xlCellTypeConstants? I would have thought Visible would work...never mind, it just clicked! Using constants I don't have to have my check for HasFormula. Duh! You make it look so easy!

    Thanks to everyone for all the help on this one. I think you've all improved my coding loads. I appreciate all your efforts.

    Thanks, and Happy New Year,
    John

  7. #7
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Re: Clean the UsedRange

    Roy,

    I just noticed your code uses "ClearContents", not "CleanString". How do we adapt it? I tried
    Please Login or Register  to view this content.
    but that resulted in an error.

  8. #8
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Clean the UsedRange

    Try:
    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Re: Clean the UsedRange

    Thanks Whizbang; that does the trick! Thanks so much for the followthrough.

    Happy New Year!

+ 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