Deleting unwanted columns

  • Hi all!

    I desperately need some help from you all.

    I download a massive volume of data from some data service into excel before I could use them for analysis each day. I can't customise the download format of data. I have been manually deleting the unwanted columns each day & it's getting a little too much.

    Can anyone please help me with the following exercise:

    The downloaded data are in the following format:

    Date prod1 cons1 cons2 sales1 prod2 cons1 cons2 sales2 ....

    The data I need are the sales figures for each unit for each day.
    I want to delete all 3 columns before each sales data. How do I write a macro to do that?

    Your help is truly appreciated.

    Thanks in advance.


  • Re: Deleting unwanted columns

    If the headings are like you have posted try this macro

  • Re: Deleting unwanted columns

    Thanks royUK.

    I think I didn't describe the problem as clearly as I should. The headings are not quite exactly like that, but they consist words as seen in my previous post. Is there anyway that I can write a macro to delete the 3 consecutive columns after a column in a repetitive manner?

    Say if col A is my 1st col... The macro will first delete cols B, C & D, then cols F, G & H, followed by cols J, K & L till end of cols in the worksheet. The macro will delete 3 consecutive cols after the 1st & keeps the 4th col in the count each time it deletes the 3 cols.

    It may look something like this:

    A B C D E F G H I J K L M N O P...

    Delete B, C, D
    Keep E
    Delete F, G, H
    Keep I
    Delete J, K, L
    Keep M
    Delete N, O, P
    Repeat the steps till end of columns

    Thanks in advance.


  • Re: Deleting unwanted columns

    Try this.

  • Re: Deleting unwanted columns

    Thanks norie! The program works fine for me. You just don't know how much I appreciate your help... I'm trying to pick up VBA myself just recently. Hopefully, I'll be able to help other newbies like myself one day.

    Thanks again to you & royUK.


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!