+ Reply to Thread
Results 1 to 4 of 4

How to do the opposite of the attached VBA code?

  1. #1
    Registered User
    Join Date
    08-13-2004
    Posts
    66

    How to do the opposite of the attached VBA code?

    I have found the code below on the web that I use to create tabs based on the values in several cells. How do I do the opposite and delete sheets with names shown in the same cells?

    <code>
    Sub copySheet2()
    Dim rngName As Range
    Dim i As Integer
    Set rngName = ThisWorkbook.Sheets("Sheet1").Range("a1")
    Do Until rngName.Value = ""
    i = ThisWorkbook.Sheets.Count
    Sheets("Sheet2").Copy After:=Sheets(i)
    ThisWorkbook.Sheets(i + 1).Name = rngName.Value
    Set rngName = rngName.Offset(1)
    Loop
    End Sub
    </code>

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to do the opposite of the attached VBA code?

    Dkerr,
    Please use code tags with your code.
    Do you want to delete the sheets you have created?

  3. #3
    Registered User
    Join Date
    08-13-2004
    Posts
    66

    Re: How to do the opposite of the attached VBA code?

    I dont know how to tage code?

    Yes the code above will be for one button and I would like another button to delete the sheets created with the above code.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to do the opposite of the attached VBA code?

    This code deletes all sheets in your book, except sheet2.

    Please Login or Register  to view this content.

+ 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