+ Reply to Thread
Results 1 to 2 of 2

add worksheets & name

  1. #1
    Registered User
    Join Date
    09-12-2014
    Location
    London, England
    MS-Off Ver
    MS Excel 2010
    Posts
    1

    add worksheets & name

    I'm new to vba macros, so I need this macro to run for a list of names and add each name once after a worksheet has been created. The problem comes in when I have to add the name "Fantino; Alessandro & Gian Natale" is over 31 characters long the limit by which excel put into naming worksheets and I'm stuck on how to get around this problem for awhile now. The background to this is in my excel worksheet I have 6 column, column 3 is my names and I want to copy all that data across to each of the active worksheets.

    Here is the vba code:

    Sub AddSheets()
    Dim producerName As String
    Dim rowCounter As Integer
    Dim outputRow As Integer
    Dim headCounter As Integer

    headCounter = 1
    rowCounter = 2

    Do
    producerName = Sheets("List").Cells(Left(rowCounter, 31), 3)

    If producerName <> "" Then

    On Error Resume Next
    If (Sheets(producerName).Name = "") Then
    Sheets.Add After:=Sheets(Sheets.Count)
    ActiveSheet.Name = producerName
    outputRow = 2
    Sheets("List").Range(Sheets("List").Cells(headCounter, 1), Sheets("List").Cells(headCounter, 6)).Copy
    Sheets(producerName).Range(Sheets(producerName).Cells(headCounter, 1), Sheets(producerName).Cells(headCounter, 6)).PasteSpecial

    End If

    Sheets("List").Range(Sheets("List").Cells(rowCounter, 1), Sheets("List").Cells(rowCounter, 6)).Copy
    Sheets(producerName).Range(Sheets(producerName).Cells(outputRow, 1), Sheets(producerName).Cells(outputRow, 6)).PasteSpecial

    rowCounter = rowCounter + 1
    outputRow = outputRow + 1
    End If

    Loop Until producerName = ""

    End Sub


    Please help me

    Jun

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: add worksheets & name

    Welcome to the forum. Unfortunately:

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 06-11-2014, 10:49 AM
  2. Replies: 2
    Last Post: 05-06-2013, 08:53 AM
  3. Copy and paste data in different worksheets of workbookA to diff worksheets in workbookB
    By preciousmetal2004 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-24-2012, 05:50 PM
  4. Replies: 1
    Last Post: 10-30-2012, 06:34 PM
  5. Copying Worksheets from Multiple Workbooks to a Single Workbook, Separate Worksheets
    By Abhi_1977 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-27-2012, 11:32 AM

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