Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default find worksheet by FindMethod

Good Day Group,

Trying to use the FindMethod to lookup if a Worksheet is present.
An effort to code as below. Seems I need further advise. Thankkful
for any help.

Brgds

CG Rosén


Dim nme As String
nme = TextBox1.Text & TextBox2.Text
Dim wk As Worksheets

Dim k
With ActiveWorkbook.Worksheets
Set k = .Find(????, LookIn:=????)

If Not k Is Nothing Then

code.....

End If
End With


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default find worksheet by FindMethod

Don't use FInd, it' a wrong tool for the task

I would do this:

Function IsPresent (ws_name as string, wb_name as string) as boolean
Dim ws as worksheet
Dim wb as Workbook

set wb=application.workbooks(wb_name)

IsPresent = false ' assume there is no such ws in this wb

for each ws in wb
if ws.name = ws_name then
isPresent=True
exit function
end if
next ws
end function

To use this function, just type

if IsPresent("MySheet_name", "MyBook_name") then ....

Cheers,

RADO




"CG Rosén" wrote in message
...
Good Day Group,

Trying to use the FindMethod to lookup if a Worksheet is present.
An effort to code as below. Seems I need further advise. Thankkful
for any help.

Brgds

CG Rosén


Dim nme As String
nme = TextBox1.Text & TextBox2.Text
Dim wk As Worksheets

Dim k
With ActiveWorkbook.Worksheets
Set k = .Find(????, LookIn:=????)

If Not k Is Nothing Then

code.....

End If
End With




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default find worksheet by FindMethod

Dim nme As String
nme = TextBox1.Text & TextBox2.Text
Dim wk As Worksheet

On Error Resume Next
set wk = Worksheets(nme")
On Error Goto 0

if not wk is Nothing then
' worksheet exists (wk holds a reference to it)

--
Regards,
Tom Ogilvy



"CG Rosén" wrote in message
...
Good Day Group,

Trying to use the FindMethod to lookup if a Worksheet is present.
An effort to code as below. Seems I need further advise. Thankkful
for any help.

Brgds

CG Rosén


Dim nme As String
nme = TextBox1.Text & TextBox2.Text
Dim wk As Worksheets

Dim k
With ActiveWorkbook.Worksheets
Set k = .Find(????, LookIn:=????)

If Not k Is Nothing Then

code.....

End If
End With




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default find worksheet by FindMethod

set wk = Worksheets(nme")
shouldn't have the doublequote

set wk = Worksheets(nme)

--
Regards,
Tom Ogilvy

Tom Ogilvy wrote in message
...
Dim nme As String
nme = TextBox1.Text & TextBox2.Text
Dim wk As Worksheet

On Error Resume Next
set wk = Worksheets(nme")
On Error Goto 0

if not wk is Nothing then
' worksheet exists (wk holds a reference to it)

--
Regards,
Tom Ogilvy



"CG Rosén" wrote in message
...
Good Day Group,

Trying to use the FindMethod to lookup if a Worksheet is present.
An effort to code as below. Seems I need further advise. Thankkful
for any help.

Brgds

CG Rosén


Dim nme As String
nme = TextBox1.Text & TextBox2.Text
Dim wk As Worksheets

Dim k
With ActiveWorkbook.Worksheets
Set k = .Find(????, LookIn:=????)

If Not k Is Nothing Then

code.....

End If
End With






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
how to find and unlink current worksheet from old worksheet kmjmail Excel Discussion (Misc queries) 3 January 12th 09 10:52 PM
Find worksheet LantzK Excel Discussion (Misc queries) 1 May 23rd 08 05:19 PM
Find Max Value in WorkSheet Corey Excel Worksheet Functions 11 January 14th 07 11:00 PM
Range in FindMethod? CG Rosén Excel Programming 1 November 12th 03 05:32 PM
Find top of worksheet D. McDonough Excel Programming 1 August 18th 03 10:36 PM


All times are GMT +1. The time now is 02:55 PM.

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

About Us

"It's about Microsoft Excel"