Need A macro to inseet new sheets with given names

Dilusha

Board Regular
Joined
May 5, 2012
Messages
58
I have following data in sheet1(Column A)
SSS
SSS
EXP
KIK
KIK
KIK
MIC
SNS
SNS
TRF


<tbody>
</tbody>

I want to insert new sheets by giving above names to same work book(only one sheet for one name. here 6 sheets ) . column A is sorted .
I use excel 2007 -in my lap top .
please help me .
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
See if this does what you want.
Code:
Sub Add_Sheets()
  Dim c As Range
  Dim ws As Worksheet
  
  With Sheets("Sheet1")
    For Each c In .Range("A2", .Range("A" & .Rows.Count).End(xlUp))
      On Error Resume Next
      Set ws = Sheets(c.Value)
      On Error GoTo 0
      If ws Is Nothing Then Sheets.Add.Name = c.Value
      Set ws = Nothing
    Next c
  End With
End Sub

Or you might want this for the line that adds the sheets
Code:
If ws Is Nothing Then Sheets.Add(After:=Sheets(Sheets.Count)).Name = c.Value
 
Last edited:
Upvote 0
See if this does what you want.
Code:
Sub Add_Sheets()
  Dim c As Range
  Dim ws As Worksheet
  
  With Sheets("Sheet1")
    For Each c In .Range("A2", .Range("A" & .Rows.Count).End(xlUp))
      On Error Resume Next
      Set ws = Sheets(c.Value)
      On Error GoTo 0
      If ws Is Nothing Then Sheets.Add.Name = c.Value
      Set ws = Nothing
    Next c
  End With
End Sub

Or you might want this for the line that adds the sheets
Code:
If ws Is Nothing Then Sheets.Add(After:=Sheets(Sheets.Count)).Name = c.Value




it workes
thanks a lot
 
Upvote 0

Forum statistics

Threads
1,214,972
Messages
6,122,530
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top