+ Reply to Thread
Results 1 to 5 of 5

Macro VBA - Remove empty rows and columns with total deleted in msg

  1. #1
    Registered User
    Join Date
    11-24-2015
    Location
    South Africa
    MS-Off Ver
    2013 Pro
    Posts
    2

    Thumbs up Macro VBA - Remove empty rows and columns with total deleted in msg

    Hi All,

    First post here, I hope someone can assist.

    I have my code here and just need a msg displaying the total of rows & columns deleted by my macro.

    Please advise.

    Regards.



    Not sure how to upload the code though
    Macro_Remove_Blanks MyEdit.txt

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro VBA - Remove empty rows and columns with total deleted in msg

    You'll need to build two counter variables for the rows and columns deleted inside your loop and increment the variables each time a deletion happens. Then read the variables into your closing message box.

    You can upload your workbook in much the same way as you did with your text file.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,163

    Re: Macro VBA - Remove empty rows and columns with total deleted in msg

    Oops, wrong post
    Last edited by Rick_Stanich; 11-24-2015 at 11:10 AM.
    Regards

    Rick
    Win10, Office 365

  4. #4
    Registered User
    Join Date
    11-24-2015
    Location
    South Africa
    MS-Off Ver
    2013 Pro
    Posts
    2

    Arrow Re: Macro VBA - Remove empty rows and columns with total deleted in msg

    Hi Richard,

    Thanks for your suggestion, I've edited the code, can you please verify for me and maybe advise on any improvements.

    I've saved the vb as an add in to add to the end users ribbon, I've also simplified the msg's.



    PS.
    (Could not attache the add in file with the code, had to put in txt again sorry.)

    Edited.txt

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro VBA - Remove empty rows and columns with total deleted in msg

    Hi,

    Personally I prefer to avoid loops for this sort of stuff, certainly as far as deleting rows is concerned. Loops just carry too much of a time overhead if large ranges are involved. Filtering the rows to delete is the fastest way I know. Once filtered then use code like
    Please Login or Register  to view this content.
    I use that a lot for getting rid of rows. As far as columns are concerned then obviously there's not the equivalent of row filtering functionality but you could use the same .SpecialCells(xlCellTypeVisible) approach to temporarily hide all the columns you want to keep, leaving those you want to delete and then just delete the entire range in one hit as with the row filtering method before unhiding all the columns.

    Apart from the speed advantage the code to do this is no more than two or three lines for the row delete and probably not many more for the column delete.

    Hope this gives you further thoughts.

+ 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 macro to delete all empty rows and columns
    By specialist1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2015, 04:01 PM
  2. [SOLVED] Remove Empty Rows ,Columns & Sort
    By johncena in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-18-2013, 03:40 AM
  3. excel macro to remove specific columns and rows + remove duplicate
    By garrywelson in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-17-2013, 12:03 PM
  4. Hide columns if rows empty
    By melewis212 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-25-2012, 06:55 PM
  5. Help remove the empty columns or rows
    By SimonLee in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-20-2011, 11:20 PM
  6. Empty Rows automatically deleted/removed??
    By toddmderossi in forum Excel General
    Replies: 2
    Last Post: 02-28-2010, 09:19 PM
  7. Deleted empty row for some columns
    By Andri in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-25-2005, 09:45 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