+ Reply to Thread
Results 1 to 7 of 7

VB Code to delete specific Columns of a specific worksheet

  1. #1
    Registered User
    Join Date
    09-21-2010
    Location
    Geneva, Switzerland
    MS-Off Ver
    Excel 2003
    Posts
    15

    VB Code to delete specific Columns of a specific worksheet

    Hey Guys,

    I honestly tried to make use of my PHP knowledge to get this right but I haven't been able to.

    What I am looking for is a macro that deletes certain columns (identified by ID # or name) in a worksheet that I specify by name.

    Any ideas?

    Thanks in advance!

    Best,
    Andy
    Last edited by akh; 09-22-2010 at 05:33 AM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: VB Code to delete specific Columns of a specific worksheet

    Try this
    Please Login or Register  to view this content.

    Where RowNo is the row that contains your header names
    And
    arrCols is an array with the column headers of the columns you need to delete.

    Hope this helps.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Registered User
    Join Date
    09-21-2010
    Location
    Geneva, Switzerland
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: VB Code to delete specific Columns of a specific worksheet

    Hey Marcol,

    Thanks a dozen, that is perfect... however the main problem remains that it needs to be specified to one sheet, this is where I fail, I try to put an if on top of that specifying that loop solely for If worksheet.Name = "SU11 Master File" <- that is the sheet name btw... and I break the whole thing.

    I swear I wish VB were the same as PHP :-P

    Can ya help me out?

    Best,
    Andy

  4. #4
    Registered User
    Join Date
    09-21-2010
    Location
    Baltimore
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: VB Code to delete specific Columns of a specific worksheet

    In the above example, define a Worksheet and then refer to it in the calls... Edited the previous poster's code, but didn't test myself....

    Please Login or Register  to view this content.

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: VB Code to delete specific Columns of a specific worksheet

    Try this
    Please Login or Register  to view this content.

    Hope this helps

    [EDIT]
    Sorry neilberl I was distracted while typing this post and didn't see your reply until I posted.
    Well on the bright side, at least we can compare codes and akh see how to use a With Statement. Go Team ..!!!...
    Last edited by Marcol; 09-22-2010 at 08:42 AM.

  6. #6
    Registered User
    Join Date
    09-21-2010
    Location
    Geneva, Switzerland
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: VB Code to delete specific Columns of a specific worksheet

    You guys are amazing... I gotta finish one other task at work and I'd say in about an hour you'll what what combination of your codes did the perfect job.

    Just a warning... I might need one more very minor simple piece of code after... then I'll have everything I need.

    I'll be more than happy to explain what it was that I am building here then... I thought at least some knowledge of what you helped me create will give ya some satisfaction.... aside from being very cool and helpful :-)

  7. #7
    Registered User
    Join Date
    09-21-2010
    Location
    Geneva, Switzerland
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: VB Code to delete specific Columns of a specific worksheet

    Alright, so 2/3 of my steps are complete... now I need to (ironically) add the step that comes before the one I have the answer to.

    This is a sub that will copy the top row of a specified worksheet and put it on top of the summary worksheet (the headers), while moving all the data in the main sheet down by one (hence not overwriting anything).

    You guys are my heros already.

    Best,
    Andy

+ 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