Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
i'm looking for a way to know if a sheet exist with the name (ex : "01J") if it doesn't exist , i have to create it ... thanks for any help. ------ Laurent. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Laurent,
Here is some code Sub test() If Not SheetExists("ABC") Then ActiveWorkbook.Worksheets.Add after:=Worksheets(Worksheets.Count) ActiveSheet.Name = "ABC" End If End Sub Function SheetExists(Filename As String) Dim oSh As Worksheet On Error Resume Next Set oSh = ActiveWorkbook.Worksheets(Filename) On Error GoTo 0 SheetExists = Not oSh Is Nothing End Function -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "LoloSoft" wrote in message ... Hi, i'm looking for a way to know if a sheet exist with the name (ex : "01J") if it doesn't exist , i have to create it ... thanks for any help. ------ Laurent. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, Bob,
thanks for the fast response !. -- Laurent. -- Laurent. "Bob Phillips" a écrit dans le message de news: ... Laurent, Here is some code Sub test() If Not SheetExists("ABC") Then ActiveWorkbook.Worksheets.Add after:=Worksheets(Worksheets.Count) ActiveSheet.Name = "ABC" End If End Sub Function SheetExists(Filename As String) Dim oSh As Worksheet On Error Resume Next Set oSh = ActiveWorkbook.Worksheets(Filename) On Error GoTo 0 SheetExists = Not oSh Is Nothing End Function -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "LoloSoft" wrote in message ... Hi, i'm looking for a way to know if a sheet exist with the name (ex : "01J") if it doesn't exist , i have to create it ... thanks for any help. ------ Laurent. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Laurent,
Something like this will work: Public Function gbWSExists(rsShtName As String) As Boolean On Error Resume Next gbWSExists = Len(Worksheets(rsShtName).Name) On Error GoTo 0 End Function -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] LoloSoft wrote: Hi, i'm looking for a way to know if a sheet exist with the name (ex : "01J") if it doesn't exist , i have to create it ... thanks for any help. ------ Laurent. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am making the assumption 01J would be a worksheet.
Dim sh as Worksheet On error resume next set sh = Worksheets("01J") On Error goto 0 if sh is nothing then worksheets.Add(After:=Worksheets(worksheets.count) ).Name ="01J" set sh = worksheets("01J") End if -- Regards, Tom Ogilvy "LoloSoft" wrote in message ... Hi, i'm looking for a way to know if a sheet exist with the name (ex : "01J") if it doesn't exist , i have to create it ... thanks for any help. ------ Laurent. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Want a trace a same values exist in two different sheet | Excel Worksheet Functions | |||
verify if spesific sheet exist | Excel Discussion (Misc queries) | |||
VBA: Make a new sheet if it doesn't exist | Excel Discussion (Misc queries) | |||
VBA, Make a new sheet if it doesn't exist | Excel Discussion (Misc queries) | |||
Does sheet exist? | Excel Programming |