LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default Check sheets name and open goto workbook

I am using Excel 97.

I am trying to goes to write some code which goes to the appropriate workbook.
I have a control workbook and 7 workbooks which are opened in the background.

The the first six of these workbooks are contain numerically named sheets

0000 -0999
1000 -1999
etc

but my last workbook contains names on the worksheets.

Others

I am using some code which I was sent by Tom Ogilvy which I have altered to
suit.

Dim BadgeNumber as Variant

BadgeNumber = InputBox(prompt:="Please enter Collar Number" _
+ Chr(13) + "(with leading zeros as appropriate)" _
+ Chr(13) + "or just Surname for Inspecting ranks or Police Staff.")

On Error GoTo CheckSheet

Select Case BadgeNumber
Case 1 To 1000

Case 1001 to 2000 etc...

Case Else

I thought that if I entered a name it would go to the Case Else field but
unfortunately it doesn't! So when I type a name as the BadgeNumber it debugs
so I added this -

CheckSheet:

On Error Resume Next

Workbooks("Lieu Leave - (Others)").Activate

Set wSheet = Sheets(BadgeNumber)
If wSheet Is Nothing Then 'Doesn't exist

MsgBox "Worksheet does not exist", _
vbCritical, "Validater"

Else 'Does exist
MsgBox "Sheet does exist", _
vbInformation, "Validater"

Set wSheet = Nothing

On Error GoTo 0

When I run this - if a sheet does exist then it works fine, but if it
doesn't again it debugs.

Can anyone assist me a solution which looks up both types of worksheets,
please?

Thanks

Mark
 
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
VBA to check is someone else has a workbook open Jim K.[_2_] Excel Discussion (Misc queries) 2 August 29th 08 04:32 PM
If Then to check if a workbook is open Shawn Excel Discussion (Misc queries) 5 November 25th 06 04:29 PM
Check if workbook open dkipping Excel Discussion (Misc queries) 4 May 24th 06 02:00 PM
Search open sheets in workbook and insert into open sheet punx77 Excel Discussion (Misc queries) 0 March 6th 06 05:07 PM
Check for open workbook georgio Excel Programming 2 November 20th 04 11:03 PM


All times are GMT +1. The time now is 02:04 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"