+ Reply to Thread
Results 1 to 9 of 9

Macro to delete some columns

  1. #1
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Macro to delete some columns

    Hi,

    please i want to delete all columns if the value = zero in specific row

    i did this code to hide the columns, can u help to delete them?

    Please Login or Register  to view this content.
    thanks.

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Macro to delete some columns

    Try

    Please Login or Register  to view this content.
    If you like my contribution click the star icon!

  3. #3
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: Macro to delete some columns

    Sorry,

    looks like not working....
    thanks.

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Macro to delete some columns

    Then probably the columns are not hidden yet.

    Please try this code

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: Macro to delete some columns

    Ollie,

    Ur macro is working very good, but if there is a lot of columns to be deleted will not work perfectly, i mean that i have to run the macro many times to delete all column

    Could u plz help

    Thanks

  6. #6
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Macro to delete some columns

    That is probably because the macro is deleting the columns from left to right. This can cause a problem because the letters of the columns will change once you delete a column that is on the left. We should reverse the process (i.e. delete from right to left).

    Try:

    Please Login or Register  to view this content.
    Last edited by OllieB; 02-07-2013 at 03:09 AM.

  7. #7
    Forum Contributor
    Join Date
    12-20-2012
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    171

    Re: Macro to delete some columns

    thanks a lot OllieB,

    it is working

  8. #8
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Macro to delete some columns

    Good to hear and you are welcome. Please remember to mark your thread as SOLVED and to click on the star icon if you are happy with my contribution!

  9. #9
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Macro to delete some columns

    PS


    the code posted in #6 contains one small typing error

    the last occurence of the below statement

    Please Login or Register  to view this content.
    should be

    Please Login or Register  to view this content.
    I have corrected the code posted in #6

+ 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