how to create a new sheet when adding values in column if it not e

  • Thread starter Thread starter Mahdi
  • Start date Start date
M

Mahdi

What i want to do , is to make excel to create a new sheet, with the name of
the content of the cells in a defined column.

so that when i edit a new cell in that column, excel will create a new sheet
with the name of the sheet being equal to the content i entered in the cell.

that is the main question.

and after that :
- how to check if the sheet is already created with that name ?!

Thanks in advance.
 
Select the sheet tab which you want to work with. Right click the sheet tab
and click on 'View Code'. This will launch VBE. Paste the below code to the
right blank portion. Get back to to workbook and try out.


Private Sub Worksheet_Change(ByVal Target As Range)
Dim ws As Worksheet, wsActive As Worksheet
On Error Resume Next

If Target.Address = "$A$1" Then
Set ws = Worksheets(CStr(Range("A1")))
If ws Is Nothing Then
Application.EnableEvents = False
Set wsActive = ActiveSheet
Set ws = Sheets.Add(After:=Sheets(Sheets.Count))
ws.Name = CStr(Range("A1"))
wsActive.Activate
Application.EnableEvents = True
End If
End If
End Sub
 
Back
Top