ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA, Make a new sheet if it doesn't exist (https://www.excelbanter.com/excel-discussion-misc-queries/87054-vba-make-new-sheet-if-doesnt-exist.html)

PaulW

VBA, Make a new sheet if it doesn't exist
 
Sub Button1_Click()

inset = Range("B3").Value
Sheets.Add
ActiveSheet.Name = "inset"
On Error GoTo Dele
Sheets("sdfs").Select
Range("A2").Select

Dele: ActiveSheet.Delete

End Sub

I'm wanting this button to make a new sheet within the workbook, named as
whatever is in B3 on the same sheet as the button. I only want it to do this
if this sheet does not already exist.

Its for recording productivity, and each sheet will be a person, and I want
part of the code to make a new sheet if that person doesn't already have a
sheet, new staff etc.

Don Guillett

VBA, Make a new sheet if it doesn't exist
 
try this idea from a recent post of mine
Sub mynewsheets()
For Each c In Range("myrange")
On Error Resume Next
If Sheets.Name < c Then
Sheets.Add.Name = c
End If
Next c
End Sub

--
Don Guillett
SalesAid Software

"PaulW" wrote in message
...
Sub Button1_Click()

inset = Range("B3").Value
Sheets.Add
ActiveSheet.Name = "inset"
On Error GoTo Dele
Sheets("sdfs").Select
Range("A2").Select

Dele: ActiveSheet.Delete

End Sub

I'm wanting this button to make a new sheet within the workbook, named as
whatever is in B3 on the same sheet as the button. I only want it to do
this
if this sheet does not already exist.

Its for recording productivity, and each sheet will be a person, and I
want
part of the code to make a new sheet if that person doesn't already have a
sheet, new staff etc.





All times are GMT +1. The time now is 02:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com