+ Reply to Thread
Results 1 to 4 of 4

Macro: Deleting a range of specified columns

  1. #1
    Registered User
    Join Date
    02-11-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    6

    Macro: Deleting a range of specified columns

    Hi,

    First post on these forums so please point out if I am doing something wrong!

    I am attempting to create a macro to delete a range of columns in the one sheet. To be clear, the whole column can be deleted... I don't need any of the data in the specified range. I am not sure if a solution has been posted to this problem yet (I did do some searching with no result). Below is my own muddled attempt at creating the macro, each time it's run I get a 1004 runtime error ("Method 'Range' of obeject '_Global' failed").

    Sub DeleteColumn()
    Range("G:H,K:M,O:R,T:AB,AD:AU,A,AW:DU,DW:DY,EA:EX,EZ:HS").Delete Shift:=xlToLeft
    End Sub

    Thanks in advance!

  2. #2
    Forum Contributor
    Join Date
    01-03-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: Macro: Deleting a range of specified columns

    Hi mbus, your code should be like this:
    Please Login or Register  to view this content.
    Edit:

    Sorry mbus, my mistake - I didn't test your code. It doesn't need to have .Columns
    But anyway I found the problem
    Please Login or Register  to view this content.
    It should be A:A if you try to delete column A

    Once again sorry
    Last edited by Sbarro79; 02-11-2013 at 09:56 PM.

  3. #3
    Registered User
    Join Date
    02-11-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Macro: Deleting a range of specified columns

    D'oh!

    Thanks for the help Sbarro, really appreciate it.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro: Deleting a range of specified columns

    Deleted: too late

+ 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