Thread
:
Test if sheet exits, create with name if not
View Single Post
#
5
Posted to microsoft.public.excel.programming
Don Guillett[_4_]
external usenet poster
Posts: 2,337
Test if sheet exits, create with name if not
try this. It will make it if if does not exist.
Sub namenewsheet()
Dim ns As Worksheet
myname = "mynewsheetname"
'myname=range("d1").value
On Error Resume Next
Set ns = ActiveWorkbook.Worksheets(myname)
On Error GoTo 0
If sht Is Nothing Then Sheets.Add.Name = myname
End Sub
--
Don Guillett
SalesAid Software
"bramweisman" wrote in message
...
I have some code that successfully imports data into worksheets. I have
a variable HOTSHEET that contains the text string from a certain cell.
How can I test to see if this sheet exits, and if not create one with
the proper name. I saw Tom Oglvy's response to Steph on a similar
subject but couldn't really make sense of it in this context.
--
bramweisman
------------------------------------------------------------------------
bramweisman's Profile:
http://www.excelforum.com/member.php...fo&userid=1746
View this thread:
http://www.excelforum.com/showthread...hreadid=271289
Reply With Quote
Don Guillett[_4_]
View Public Profile
Find all posts by Don Guillett[_4_]