+ Reply to Thread
Results 1 to 13 of 13

Removing blanks where blanks show blank but are code to show blank.

  1. #1
    Forum Contributor
    Join Date
    03-25-2011
    Location
    London, England
    MS-Off Ver
    office 2021
    Posts
    318

    Removing blanks where blanks show blank but are code to show blank.

    Hi Guys
    I have the following code which was kindly given to me by a colleague at ExcelForum. It was designed to remove one row if that row was empty which it does. I have tried to use it in another location where there are several hundred blank rows which it was not designed for and takes a very long time removing some. Eventually having moved some it gives up.
    Firstly I can’t work out why it is removing some as they appear identical to the ones not removed
    Secondly it is very slow.
    So is there any code that would remove these blanks.
    Here is the code I have

    Please Login or Register  to view this content.

    The problem is that I have now run a macro to pull from another sheet the data I need. The macro shows “ “ in the cells I do not need but behind that there is the code. I do not know how Excel recognises this. If anyone has a suggestion I would be thrilled.
    I am uploading the workbook which puts my comments into context. The sheet I am working in is Petty cash and the data is being pulled from BDC2. The macro (4) has just been run. There are entries in the petty cash sheet. Some of the columns are hidden because there are not needed.

    Thanks in advance
    Mark
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Removing blanks where blanks show blank but are code to show blank.

    Hi mark

    Try this link

    http://www.ozgrid.com/VBA/VBACode.htm

  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Removing blanks where blanks show blank but are code to show blank.

    Well in your workbook code, the bit that you have put in the post that deletes the empty rows has been commented out? I'd suggest you need to step through backwards though otherwise it will skip rows:
    Please Login or Register  to view this content.

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Removing blanks where blanks show blank but are code to show blank.

    You can also try this code as well

    Please Login or Register  to view this content.
    Hope this helps.
    Last edited by sktneer; 11-07-2013 at 11:12 AM.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  5. #5
    Forum Contributor
    Join Date
    03-25-2011
    Location
    London, England
    MS-Off Ver
    office 2021
    Posts
    318

    Re: Removing blanks where blanks show blank but are code to show blank.

    Hi Yudlugar and Sktneer

    Youlugar I am not sure where to enter this code. I have played about with it to no avail.

    And Sktneer I copied you code into my VBA and ran it. Nothing happened.

    Still trying to see how to use either one.

    Mark

  6. #6
    Forum Contributor
    Join Date
    03-25-2011
    Location
    London, England
    MS-Off Ver
    office 2021
    Posts
    318

    Re: Removing blanks where blanks show blank but are code to show blank.

    I had gone through all the macros on this sheet before posting my question. Still do not have the solution. I am sure it is somewhere but where? Thanks.

  7. #7
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Removing blanks where blanks show blank but are code to show blank.

    Mark, your "Macro4" should be:
    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Removing blanks where blanks show blank but are code to show blank.

    This worked for me:-

    Please Login or Register  to view this content.

  9. #9
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Removing blanks where blanks show blank but are code to show blank.

    Quote Originally Posted by markDuffy View Post

    And Sktneer I copied you code into my VBA and ran it. Nothing happened.

    Mark
    I don't understand that what do you mean by nothing happened.
    When I ran the code, Only 73 rows were left on petty cash sheet in comparison to 873 rows initially. The code deleted all the rows based on your criteria.
    Please see the attachment. The code is on Module3. You can compare the attached sheet with the sheet you uploaded in post#1 to see if you get the desired result.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    03-25-2011
    Location
    London, England
    MS-Off Ver
    office 2021
    Posts
    318

    Re: Removing blanks where blanks show blank but are code to show blank.

    Hi Sktneer
    I must have copied something incorrectly or other. I have run yours as above and its great. I don't know how to apologise enough as the time and effort given by you is so appreciated. I will now go back and see where I went wrong. I am learning every time I do something but it is not recognisable to me yet to spot where i have done something incorrect.

    But thank you very very much

    All the Best
    Mark

  11. #11
    Forum Contributor
    Join Date
    03-25-2011
    Location
    London, England
    MS-Off Ver
    office 2021
    Posts
    318

    Re: Removing blanks where blanks show blank but are code to show blank.

    Hi Yudlugar

    Thanks again for a delightful piece of code. Don't know how long it is going to take me till I am able to write code which does what it should. I will keep studying what you have given me and see how much of it I can understand. I may have committed a most cardinal sin in that I had not tested correctly the code given to me by Sktneer which actually worked. By studying that also there is a hope I will improve.

    All the Best Mark

  12. #12
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Removing blanks where blanks show blank but are code to show blank.

    Never mind. Glad to help you. Thanks for the feedback and the rep.

  13. #13
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Removing blanks where blanks show blank but are code to show blank.

    Mark,

    Not a problem - few pointers:

    -I think one of the reasons your original code was running very slowly was that everytime you deleted a line of code the entire sheet recalculated itself. This takes a bit of time when you have so many formulas in the sheet.

    -Your original code assigned the same r1c1 formula to several columns individually, this was unneccessary, you could do it all in one go.

    -When deleting rows, you need to loop backwards otherwise you will skip some.

+ 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. VBA Code to Copy Non Blanks/Cells with Values until Formula returns as blank
    By FLani in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-16-2013, 10:18 PM
  2. [SOLVED] Find first non-blank cell after a group of blanks copy offset cells, find next blank, loop
    By gwsampso in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-21-2012, 06:11 AM
  3. Replies: 4
    Last Post: 08-29-2012, 02:45 PM
  4. Replies: 1
    Last Post: 04-26-2008, 08:00 AM
  5. [SOLVED] Hide show blanks
    By PCOR in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-26-2005, 05:19 PM

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