I'm trying to take a master tab,
1. read column A,
2. create a tab in that workbook with the name found in column a,
3. then copy that one line from the master into the newly created tab.
I have the code (below) that cycles thru column A and creates the tabs but having issue with copying the first line into the newly created workbook. Any suggestions?
Thanks
'code to move only the line from master tab where we got the name of the tab to newly created tab
' Master Tab
'A B C
'A01 Cars Red
'B01 Trucks Blue
'C01 Boats White
' New tabs
' A01 <-tabname
'A B C
'A01 Cars Red
' B01 <-tabname
'A B C
'B01 Trucks Blue
' C01 <-tabname
'A B C
'C01 Boats White
1. read column A,
2. create a tab in that workbook with the name found in column a,
3. then copy that one line from the master into the newly created tab.
I have the code (below) that cycles thru column A and creates the tabs but having issue with copying the first line into the newly created workbook. Any suggestions?
Thanks
VBA Code:
Sub NewSheets()
Dim rng As Range
Dim cell As Range
Dim wb As Workbook
Dim ws As Worksheet
On Error GoTo Errorhandling
Set rng = Application.InputBox(Prompt:="Select cell range:", _
Title:="Create sheets", _
Default:=Selection.Address, Type:=8)
'Iterate through cells in selected cell range
For Each cell In rng
'Check if cell is not empty
If cell <> "" Then
'Insert worksheet and name the worksheet based on cell value
Sheets.Add.Name = cell
End If
'Continue with next cell in cell range
Next cell
'Go here if an error occurs
Errorhandling:
'Stop macro
End Sub
'code to move only the line from master tab where we got the name of the tab to newly created tab
' Master Tab
'A B C
'A01 Cars Red
'B01 Trucks Blue
'C01 Boats White
' New tabs
' A01 <-tabname
'A B C
'A01 Cars Red
' B01 <-tabname
'A B C
'B01 Trucks Blue
' C01 <-tabname
'A B C
'C01 Boats White