Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Search for a sheet

I have a work book for payroll that has a sheet for each employee. Is there a
way to write a macro that will search and select a sheet. If possible I
would like to be able to que the macro with a short cut such as Ctrl+s. I
know you can select a sheet and do Ctrl+F, but I have a summary page that is
linked to each employee sheet and it seraches through that sheet first.

Thanks,
Chance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Search for a sheet

right click on the lower left corner where you see the VCR controls. This
will give you a list of sheets to choose from.

Otherwise

Sub SelectSheet()
res = InputBox("Enter employee (sheet) name")
on Error resume next
set sh = worksheets(res)
On Error goto 0
if sh is nothing then
msgbox res & " is not a valid sheet name"
else
sh.activate
End if
End Sub

paste into a general module. go back to Excel. Go to Tools=Macro=Macros,
select the SelectSheet macro and click on options. This will allow you to
assign a shortcut key.
--
Regards,
Tom Ogilvy

"Chance224" wrote in message
...
I have a work book for payroll that has a sheet for each employee. Is

there a
way to write a macro that will search and select a sheet. If possible I
would like to be able to que the macro with a short cut such as Ctrl+s. I
know you can select a sheet and do Ctrl+F, but I have a summary page that

is
linked to each employee sheet and it seraches through that sheet first.

Thanks,
Chance



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Search for a sheet

The macro works great! The only thing is when you type in an invalid entry it
goes to Debug.

On Error GoTo 0
If sh Is Nothing Then
MsgBox res & " is not a valid sheet name"
Else
sh.Activate
End If
End Sub

Thanks,
Chance


"Tom Ogilvy" wrote:

right click on the lower left corner where you see the VCR controls. This
will give you a list of sheets to choose from.

Otherwise

Sub SelectSheet()
res = InputBox("Enter employee (sheet) name")
on Error resume next
set sh = worksheets(res)
On Error goto 0
if sh is nothing then
msgbox res & " is not a valid sheet name"
else
sh.activate
End if
End Sub

paste into a general module. go back to Excel. Go to Tools=Macro=Macros,
select the SelectSheet macro and click on options. This will allow you to
assign a shortcut key.
--
Regards,
Tom Ogilvy

"Chance224" wrote in message
...
I have a work book for payroll that has a sheet for each employee. Is

there a
way to write a macro that will search and select a sheet. If possible I
would like to be able to que the macro with a short cut such as Ctrl+s. I
know you can select a sheet and do Ctrl+F, but I have a summary page that

is
linked to each employee sheet and it seraches through that sheet first.

Thanks,
Chance




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Search for a sheet

In the vbe, go to Tools=Options, general tab and make sure you have Break
on Unhandled errors selected instead of Break on all errors.

--
Regards,
Tom Ogilvy


"Chance224" wrote in message
...
The macro works great! The only thing is when you type in an invalid entry

it
goes to Debug.

On Error GoTo 0
If sh Is Nothing Then
MsgBox res & " is not a valid sheet name"
Else
sh.Activate
End If
End Sub

Thanks,
Chance


"Tom Ogilvy" wrote:

right click on the lower left corner where you see the VCR controls.

This
will give you a list of sheets to choose from.

Otherwise

Sub SelectSheet()
res = InputBox("Enter employee (sheet) name")
on Error resume next
set sh = worksheets(res)
On Error goto 0
if sh is nothing then
msgbox res & " is not a valid sheet name"
else
sh.activate
End if
End Sub

paste into a general module. go back to Excel. Go to

Tools=Macro=Macros,
select the SelectSheet macro and click on options. This will allow you

to
assign a shortcut key.
--
Regards,
Tom Ogilvy

"Chance224" wrote in message
...
I have a work book for payroll that has a sheet for each employee. Is

there a
way to write a macro that will search and select a sheet. If possible

I
would like to be able to que the macro with a short cut such as

Ctrl+s. I
know you can select a sheet and do Ctrl+F, but I have a summary page

that
is
linked to each employee sheet and it seraches through that sheet

first.

Thanks,
Chance






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Search for a sheet

Disregards,
My omission

this should do it:

Sub SelectSheet()
Dim sh As Worksheet
res = InputBox("Enter employee (sheet) name")
On Error Resume Next
Set sh = Worksheets(res)
On Error GoTo 0
If sh Is Nothing Then
MsgBox res & " isn not a valid sheet name"
Else
sh.Activate
End If
End Sub


--
Regards,
Tom Ogilvy
"Tom Ogilvy" wrote in message
...
In the vbe, go to Tools=Options, general tab and make sure you have Break
on Unhandled errors selected instead of Break on all errors.

--
Regards,
Tom Ogilvy


"Chance224" wrote in message
...
The macro works great! The only thing is when you type in an invalid

entry
it
goes to Debug.

On Error GoTo 0
If sh Is Nothing Then
MsgBox res & " is not a valid sheet name"
Else
sh.Activate
End If
End Sub

Thanks,
Chance


"Tom Ogilvy" wrote:

right click on the lower left corner where you see the VCR controls.

This
will give you a list of sheets to choose from.

Otherwise

Sub SelectSheet()
res = InputBox("Enter employee (sheet) name")
on Error resume next
set sh = worksheets(res)
On Error goto 0
if sh is nothing then
msgbox res & " is not a valid sheet name"
else
sh.activate
End if
End Sub

paste into a general module. go back to Excel. Go to

Tools=Macro=Macros,
select the SelectSheet macro and click on options. This will allow

you
to
assign a shortcut key.
--
Regards,
Tom Ogilvy

"Chance224" wrote in message
...
I have a work book for payroll that has a sheet for each employee.

Is
there a
way to write a macro that will search and select a sheet. If

possible
I
would like to be able to que the macro with a short cut such as

Ctrl+s. I
know you can select a sheet and do Ctrl+F, but I have a summary page

that
is
linked to each employee sheet and it seraches through that sheet

first.

Thanks,
Chance









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Search for a sheet

I can use the following formula to activate a sheet. Is there a way to link
it to a msg box instead of a cell?
Sub GoToIt()
Dim s As String
s = Range("A1") 'sheet name To search In
Sheets(s).Activate

End Sub

Thanks,
Chance

"Chance224" wrote:

I have a work book for payroll that has a sheet for each employee. Is there a
way to write a macro that will search and select a sheet. If possible I
would like to be able to que the macro with a short cut such as Ctrl+s. I
know you can select a sheet and do Ctrl+F, but I have a summary page that is
linked to each employee sheet and it seraches through that sheet first.

Thanks,
Chance

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Search for a sheet

See my answer to our first post.

--
Regards,
Tom Ogilvy

"Chance224" wrote in message
...
I can use the following formula to activate a sheet. Is there a way to

link
it to a msg box instead of a cell?
Sub GoToIt()
Dim s As String
s = Range("A1") 'sheet name To search In
Sheets(s).Activate

End Sub

Thanks,
Chance

"Chance224" wrote:

I have a work book for payroll that has a sheet for each employee. Is

there a
way to write a macro that will search and select a sheet. If possible I
would like to be able to que the macro with a short cut such as Ctrl+s.

I
know you can select a sheet and do Ctrl+F, but I have a summary page

that is
linked to each employee sheet and it seraches through that sheet first.

Thanks,
Chance



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Search for a sheet

There is already a facility to present the list of sheets in a menu. On the
bottom left of your Excel screen you'll find arrow heads for navigations. If
you right click in this area a menu pops up.

"Chance224" wrote:

I have a work book for payroll that has a sheet for each employee. Is there a
way to write a macro that will search and select a sheet. If possible I
would like to be able to que the macro with a short cut such as Ctrl+s. I
know you can select a sheet and do Ctrl+F, but I have a summary page that is
linked to each employee sheet and it seraches through that sheet first.

Thanks,
Chance

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
Search a name in one sheet and entry it into another sheet Shilpi Excel Worksheet Functions 4 May 5th 09 01:11 AM
search a value in W/sheet TUNGANA KURMA RAJU Excel Discussion (Misc queries) 7 April 4th 09 01:54 AM
Search for rows in one sheet and copy into another sheet based on customer id [email protected] Excel Worksheet Functions 1 October 22nd 07 03:09 AM
Search for a Sheet Chance224 Excel Discussion (Misc queries) 3 December 14th 04 12:29 AM
search for a sheet Lee S.[_3_] Excel Programming 1 September 13th 03 01:55 AM


All times are GMT +1. The time now is 03:10 AM.

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"