![]() |
finding a tab name
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? |
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? |
finding a tab name
that works perfectly, thanks!
"Barb Reinhardt" wrote: 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? |
All times are GMT +1. The time now is 08:51 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com