+ Reply to Thread
Results 1 to 18 of 18

removing blank cells

  1. #1
    Registered User
    Join Date
    02-26-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    22

    removing blank cells

    I am not sure if this is possible to do easily but i am trying to remove all of the blanks in a document. if you look at the attached, you can see what i mean. In sheet 1 i have the messy data and sheet 2 i have what i would like the sheet to look like in the end. while this may seem easy to do using an advanced filter, the actual data i have is 150 rows by 150 columns with data spread throughout. Thanks
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    02-14-2010
    Location
    oman
    MS-Off Ver
    Excel 2003
    Posts
    384

    Post Re: removing blank cells

    try......
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-26-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: removing blank cells

    thanks. It didnt work for me when i tried to use it

  4. #4
    Registered User
    Join Date
    02-26-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: removing blank cells

    it worked for the example i gave but when i tried to apply it to a bigger set of numbers, it keeps spitting back an error

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

    Re: removing blank cells

    here's your file with the macro posted by johncena installed.
    I added a line to copy your data from sheet1 to sheet2 and then performing the blank cell deletion on sheet2.
    This way your data on sheet1 remains in tact.
    hope this helps.
    you can remove the button I added and execute the macro manually.
    modytrane.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    02-26-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: removing blank cells

    this all works great for the attachment that i gave but the data that i am using is actually in a grid that is 154 columnsx155 rows and for some reason the macro is not working in the larger data set. is there something that i need to alter in the macro to make it work. i see tha tit says "For intCol - 1 To 5" but even if i change that to 1 To 154 it still has the following error "Run-time error '1004': Application-defined or object -defined error"

    Thank you all for your help. its been great

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

    Re: removing blank cells

    OK, it should work now.
    In the attached file, I've added dummy data all the way to column FZ [which should be 182nd column], down to ROW 180+.
    The macro has a shortcut of ctrl+d.
    I've cleared sheet 2, so its blank.
    Run the macro and data will be copied to sheet2 and then compressed up.
    modytrane.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    02-26-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: removing blank cells

    do you happen to have the VBA code for that so i can run it in my other file? Thanks

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

    Re: removing blank cells

    Here's the code.

    Please Login or Register  to view this content.

    For future reference, you can open the file and enter alt+F11 and view the code in module(s).

    Good Luck.
    If you have problems, post back.

    modytrane

  10. #10
    Registered User
    Join Date
    02-26-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: removing blank cells

    It still does not seem to be working with a larger data set. i have expanded the data set in the attached. Please let me know if you are having the same issues. It all worked out great in the earlier sample but for some reason will not work with the expanded data
    Attached Files Attached Files

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

    Re: removing blank cells

    I looked at your file last night and the problem is that those "blank" cells are not really blank. I don't know if they are results of some formulas or you are downloading the data from another source. Anyway, the macro instruction I used [originally posted by johncena] is looking for "blank" cells.

    When I get a chance later, I'll modify it to look for non-zero values and delete the rest.

    modytrane.

  12. #12
    Registered User
    Join Date
    02-26-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: removing blank cells

    those cells were a result of a formula and they are paste special>values. sorry about that. i thought that would make them blank

  13. #13
    Forum Contributor
    Join Date
    02-14-2010
    Location
    oman
    MS-Off Ver
    Excel 2003
    Posts
    384

    Post Re: removing blank cells

    Quote Originally Posted by kmknowles View Post
    It still does not seem to be working with a larger data set. i have expanded the data set in the attached. Please let me know if you are having the same issues. It all worked out great in the earlier sample but for some reason will not work with the expanded data
    run first this macro & wait.it's may be take little time.to clean......
    Please Login or Register  to view this content.
    then run modytrane's macro it should work....
    Please Login or Register  to view this content.
    Last edited by johncena; 03-04-2010 at 10:35 AM.

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

    Re: removing blank cells

    kmknowles,
    Here's a solution that will work in your situation.
    See the attached example. I modified the original code from johncena's post.
    Now isteadof special cells being blank, we are looking for non-zero length text.

    Here's the macro.

    Please Login or Register  to view this content.
    Try it, it works.

    modytrane.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    02-26-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: removing blank cells

    that worked great on your attachement but i am getting the same error when i run it on my attachement from above

    When i run the first macro from JohnCena, I am getting a "Compile error: Wrong number of arguments or invalid property assignment"

    I dont know if i am doing it wrong but what i am doing is going into sheet 1 and right clicking the tab and then viewing code and copy and pasting it there. then when i click F5 i get the error.

    Thank you all for your help on this. I am trying to streamline a process that i use often and this would really help me out.

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

    Re: removing blank cells

    I had noticed this before and forgot to correct you on this.
    You are installing the macro under Sheet1.
    You should add a module and install it under module 1.
    Look at the file I sent you.
    Enter alt+F11, view the code. The macro is under module 1.
    The short cut for the macro is ctrl+d.
    modytrane.

  17. #17
    Registered User
    Join Date
    02-26-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: removing blank cells

    thank you that works perfect.

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

    Re: removing blank cells

    If you are satisfied with the solution, please mark this thread "SOLVED".
    modytrane

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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