Copy list of Names to Worksheets

Hi All,

Could some-one assist me with a Macro that will copy the Names from a list in Sheet1 to the worksheets in a workbook. It should start with the First name in the list and copy this to a cell in the First worksheet, then the second name in the list to the second worksheet. Then fill the name down. Also to rename the sheets, to the names in the list. Hope this is possible. I have attached an example spreadsheet.Thanking you in advance.

Walter

AttachmentSize
COPY NAMES TO SHEETS.xlsx11.45 KB

RE: Copy list of Names to Worksheets

Hi,

Here's some solution:

' ************************* ' ************************** '
Sub SomeSubroutine()

    Const DEST_RNG_ADDRESS As String = "B2:B13"
    
    Dim oWshNames As Worksheet
    Dim N As Integer
    Dim i As Integer
    Dim oDestWsh As Worksheet
    Dim strName As String

    
    Application.ScreenUpdating = False
    
    Set oWshNames = ThisWorkbook.Worksheets(1)
    
    N = ThisWorkbook.Worksheets.Count
    
    For i = 2 To N
        Set oDestWsh = ThisWorkbook.Worksheets(i)
        With oDestWsh
            strName = oWshNames.Cells(i, 1).Value

            
            On Error Resume Next
            ' Possible reason for error raising (this is a system message):
            '
            ' You typed an invalid name for a sheet or chart. Make sure that:
            '
            '   1) The name does not exceed 31 characters.
            '   2) The name does not contain any of the following character:
            '       : \ / ? * [ ]
            '   3) You did not leave the name blank
            .Name = strName
            Err.Clear

            
            .Range(DEST_RNG_ADDRESS).Value = strName
        End With
    Next i

    
    Set oDestWsh = Nothing
    Set oWshNames = Nothing

    
    Application.ScreenUpdating = True

End Sub
' ************************* ' ************************** '

Note: This subroutine assumes that the list of names is on the first sheet, from left to right, and it is into the first column, starting from the second row.

 

Best regards.

Thanks

Thanks a mil!