• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

create a new sheet (individual name wise) based on name list same excel file

hi i am trying to VBA Excel version is 2013

i want create a new sheet (individual name wise) based on name list same excel file

eg.

i have mention into Sheet1
1 Pune is B2, to be create new sheet with same name
2 Chennai is B3, to be create new sheet with same name , , , Etc,.
 

Attachments

  • Book2.xlsx
    10.8 KB · Views: 6
Code:
Option Explicit

Sub CreateSheets()
    Dim dicKey, dicValues, data, lastrow As Long
    Dim i As Long, ws As Worksheet, wsDest As Worksheet
    Set ws = ActiveSheet
    lastrow = Cells(Rows.Count, 1).End(xlUp).Row
    data = Range("B2:B" & lastrow) ' load data into variable
    With CreateObject("scripting.dictionary")
        For i = 1 To UBound(data)
            If .Exists(data(i, 1)) = False Then
                dicKey = data(i, 1) 'set the key
                dicValues = data(i, 1) 'set the value for data to be stored
                .Add dicKey, dicValues
                Set wsDest = Sheets.Add(After:=Sheets(Worksheets.Count))
                wsDest.Name = data(i, 1)
            End If
        Next i
    End With
End Sub
 

Attachments

  • Create Sheets.xlsm
    15.5 KB · Views: 8
Hi !​
Just using Excel basics according to the TEBV main rule and as yet posted in this forum like in others, a beginner demonstration :​
Code:
Sub Demo1()
    Dim V, R&
        V = [A1].CurrentRegion.Columns(2).Value2
    For R = 2 To UBound(V)
        If Not Evaluate("ISREF('" & V(R, 1) & "'!A1)") Then Sheets.Add(, Sheets(Sheets.Count)).Name = V(R, 1)
    Next
End Sub
Do you like it ? So thanks to click on bottom right Like !​
 
Back
Top