delete columns with excel vba

  • Hi all,


    I have used some code to delete columns. If I do it with the mouse, and then select the right mouse button (having the mouse in the column letter), it will delete all (even when there is columns with a color fill and formating).


    How can this be done using code?


    this will not work:

    Code
    1. Sub Delete_EntireColumn()
    2. Columns(1).EntireColumn.Delete
    3. End Sub


    Greetings.