Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 385
Default What's command for find sheets exist in workbooks?

I need your help for command of VBA
what's command for "find sheets("A")=ture"
please refer to under information.

if "find sheets("A")=ture" then
Worksheets("A").Delete
end if
ActiveWorkbook.Worksheets.Add
rename = ActiveSheet.Name
Worksheets(rename).Name = "A"

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 125
Default What's command for find sheets exist in workbooks?

This should help

Private Sub CommandButton1_Click()
For i = 1 To ActiveWorkbook.Worksheets.Count
Worksheets(i).Select

If Worksheets(i).Name = "Sheet3" Then MsgBox (Worksheets(i).Name)
Next

End Sub

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Jennifer" wrote:

I need your help for command of VBA
what's command for "find sheets("A")=ture"
please refer to under information.

if "find sheets("A")=ture" then
Worksheets("A").Delete
end if
ActiveWorkbook.Worksheets.Add
rename = ActiveSheet.Name
Worksheets(rename).Name = "A"

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,939
Default What's command for find sheets exist in workbooks?

if SheetExists("A")=True then
application.Dispalyalerts = false
Worksheets("A").Delete
application.DisplayAlerts = True
end if
ActiveWorkbook.Worksheets.Add
ActiveSheet.Name = "A"
....
End sub

Public Function SheetExists(SName As String, _
Optional ByVal Wb As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If Wb Is Nothing Then Set Wb = ThisWorkbook
SheetExists = CBool(Len(Wb.Sheets(SName).Name))
End Function

--
HTH...

Jim Thomlinson


"Jennifer" wrote:

I need your help for command of VBA
what's command for "find sheets("A")=ture"
please refer to under information.

if "find sheets("A")=ture" then
Worksheets("A").Delete
end if
ActiveWorkbook.Worksheets.Add
rename = ActiveSheet.Name
Worksheets(rename).Name = "A"

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 385
Default What's command for find sheets exist in workbooks?

Thanks so much
nice got your answer.
It was a successful experiment on my project.
Thanks again!

"Jim Thomlinson" wrote:

if SheetExists("A")=True then
application.Dispalyalerts = false
Worksheets("A").Delete
application.DisplayAlerts = True
end if
ActiveWorkbook.Worksheets.Add
ActiveSheet.Name = "A"
...
End sub

Public Function SheetExists(SName As String, _
Optional ByVal Wb As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If Wb Is Nothing Then Set Wb = ThisWorkbook
SheetExists = CBool(Len(Wb.Sheets(SName).Name))
End Function

--
HTH...

Jim Thomlinson


"Jennifer" wrote:

I need your help for command of VBA
what's command for "find sheets("A")=ture"
please refer to under information.

if "find sheets("A")=ture" then
Worksheets("A").Delete
end if
ActiveWorkbook.Worksheets.Add
rename = ActiveSheet.Name
Worksheets(rename).Name = "A"

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking Groups of cells between workbooks vnacj-joe Excel Discussion (Misc queries) 4 June 14th 07 05:18 PM
Worksheet Sort - but all sheets in array do not exist [email protected] Excel Discussion (Misc queries) 2 August 20th 06 02:41 AM
Links auto update on some workbooks but not others Tasza Excel Worksheet Functions 1 October 25th 05 01:04 AM
Multiple sheets selected twa14 Excel Discussion (Misc queries) 2 December 21st 04 11:15 AM
Workbooks...I'll try this again... Markster Excel Discussion (Misc queries) 10 December 7th 04 10:12 PM


All times are GMT +1. The time now is 08:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"