Results 1 to 3 of 3

I need some help creating new worksheets based on a list

Threaded View

  1. #1
    Registered User
    Join Date
    11-13-2015
    Location
    Indiana, U.S.
    MS-Off Ver
    Office 2013
    Posts
    5

    I need some help creating new worksheets based on a list

    So this code needs to look at a list on the first worksheet and create new worksheets based on that list, but only the new values. It works some of the time, but if there are no values in the list then I get an error message regarding the last If statement. Any help would be greatly appreciated!

    Here is the code so far:

    'Declare Variables
    Dim bottomA As Long
    Dim c2 As Range
    Dim ws2 As Worksheet

    'Set Range

    bottomA = Range("A" & Rows.Count).End(xlUp).Row

    'Loop through each value in range and create worksheet
    For Each c2 In Range("A2:A" & bottomA)
    Set ws2 = Nothing
    On Error Resume Next
    Set ws2 = Worksheets(c2.Value)
    On Error GoTo 0
    'set the name of the worksheet
    If ws2 Is Nothing Then
    Worksheets.Add(After:=Sheets(Sheets.Count)).Name = c.Value 'this is where the error message pops up
    End If
    Next c2

    End Sub

    I tried the new code but I am still getting an error message when there are no items on the list.
    Last edited by khan_solo; 11-13-2015 at 06:24 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Creating New Worksheets Based off a list of names
    By lorber123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-29-2015, 05:28 PM
  2. Replies: 2
    Last Post: 05-06-2013, 08:53 AM
  3. Creating New Worksheets based on a list of names
    By kchm_2000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-25-2011, 06:40 AM
  4. Creating new worksheets from given list
    By srinivas_kaship in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-02-2009, 11:41 PM
  5. Creating a list of worksheets
    By Gavin Ling in forum Excel General
    Replies: 7
    Last Post: 10-23-2008, 03:56 PM
  6. Creating List from 2 Worksheets
    By apb in forum Excel General
    Replies: 2
    Last Post: 03-26-2008, 05:07 PM
  7. Creating a list from 2 or 3 different worksheets
    By bruce in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2005, 10:06 PM

Tags for this Thread

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