+ Reply to Thread
Results 1 to 8 of 8

Clean Function to Clean Entire Sheet

  1. #1
    Registered User
    Join Date
    10-08-2008
    Location
    Indy
    Posts
    14

    Clean Function to Clean Entire Sheet

    Hello,

    I have data that has some unreadable (comes up as a box) characters. The clean function within Excel gets rid of the characters perfectly. I would like to create a macro that will clean all of the data on the sheet. I currently have data in cells A1:JD5000.

    I can use the following code to get rid of the bad characters in individual cells, but I cannot figure out how to modify it to clean the whole worksheet:

    Please Login or Register  to view this content.
    Any ideas? Thanks

  2. #2
    Forum Contributor
    Join Date
    07-24-2009
    Location
    Valrico, FL USA
    MS-Off Ver
    Excel 2016
    Posts
    358

    Re: Clean Function to Clean Entire Sheet

    See if this is what you are looking for?
    http://www.xcelfiles.com/VBA_Quick10.html

  3. #3
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: Clean Function to Clean Entire Sheet

    try;

    Please Login or Register  to view this content.
    modytrane

  4. #4
    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: Clean Function to Clean Entire Sheet

    Modytrane, the operative word was Clean, not Clear.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    10-08-2008
    Location
    Indy
    Posts
    14

    Re: Clean Function to Clean Entire Sheet

    Quote Originally Posted by ncmay View Post
    See if this is what you are looking for?
    http://www.xcelfiles.com/VBA_Quick10.html
    That does work, but it is really slow. Since there are a ton of cells that need cleaned, I could see this taking a really long time. Thanks for the link though.

  6. #6
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: Clean Function to Clean Entire Sheet

    sorry about that.
    I need new glasses or bigger screen.
    modytrane

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Clean Function to Clean Entire Sheet

    Ivan Moala is a genius (IMO) so I'd say his code is good and you are let's face it running code on over 1.3 million cells so it's never going to be quick!

    You could toggle the App level settings and see if that helps... (screenupdate etc...), also on an aside the code utilises SpecialCells so as to restrict number of cells being iterated - given the vast range I suspect you *may* need to iterate your range in blocks given there is a limit on how many non-contiguous ranges SpecialCells can handle (resolved in 2010 apparently).

    You could also contemplate running an Evaluate call rather than Iteration, however, again given volume of cells I have little idea as to the performance impact that approach would have!
    (EDIT: and Evaluate probably not viable if you have lengthy strings)
    Last edited by DonkeyOte; 11-05-2009 at 09:09 AM.

  8. #8
    Registered User
    Join Date
    10-08-2008
    Location
    Indy
    Posts
    14

    Re: Clean Function to Clean Entire Sheet

    Prior to trying to produce my own code, I recorded a macro that was doing the job in about 20-30 seconds. I simply inserted a column next to any column that had the unwanted characters, used the clean function and copied it down, copy and pasted values, then deleted the old column.

    I was hoping I could just rewrite the code I posted above to something like this:

    Please Login or Register  to view this content.
    I guess it's not that simple.

+ 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