View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default finding a tab name

Try something like this

Dim s1 As String
Dim WS As Worksheet

s1 = "TEST"

Set WS = Nothing
On Error Resume Next
Set WS = Sheets(s1)
On Error GoTo 0

If WS Is Nothing Then
Set WS = Worksheets.Add(After:=Worksheets(Worksheets.Count) )
WS.Name = s1
End If


HTH,
Barb Reinhardt

"tigoda" wrote:

I have a list of tab names and data, I can set a string as the tab name and
go to it using

Sheets(S1).Select

However, if the tab is not found I need to create it, how can this be done?