+ Reply to Thread
Results 1 to 3 of 3

Delete Columns and hide sheets

Hybrid View

  1. #1
    Registered User
    Join Date
    07-07-2008
    Location
    North Carolina
    Posts
    24

    Delete Columns and hide sheets

    I have a workbook that has 7 worksheets in it (Criteria, Sheet 1, Sheet2, Sheet 3, Sheet 4, Master, Sheet 6, List).

    After I run another macro, I want to make excel automatically delete column a from sheet 1 and sheet 2 and then automatically delete column c from sheet 2. Once that is done I need to hide sheets Master, Sheet 6, and List. I have tried this but keep getting errors.

    Here is some of the code that I was looking at.

    Columns("A:A").Select
        Selection.Delete Shift:=xlToLeft
        Columns("B:B").Select
        Selection.Delete Shift:=xlToLeft
    Thanks for any assistance you can provide.
    Danielle

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    dodom75,

    Please read forum rules below, I've wrapped your code for you this time.

    You could try

    Dim Wsht As Worksheet
    
    With Sheets("Sheet2")
        .Columns(1).Delete Shift:=xlToLeft
        .Columns(3).Delete Shift:=xlToLeft
    End With
    
    Sheets("Sheet1").Columns(1).Delete Shift:=xlToLeft
        
    For Each Wsht In Worksheets
        Select Case LCase(Wsht.Name)
            Case "master", "sheet 6", "list"
            Wsht.Visible = False
        End Select
    Next Wsht
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    07-07-2008
    Location
    North Carolina
    Posts
    24

    Delete Columns and Hide Sheets, Answered.

    Thank you, this worked perfectly.

+ 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