#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default basic

I want to create a macro that creates a pop up box that ask the name of
the worksheet i want to open. What statement do i use?
please help :

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default basic

Ella,

It is "workbooks" that are opened, not worksheets.
Use "GetOpenFileName"...
'-------------------------
Sub MakeItHappen()
Dim FileToOpen As Variant
FileToOpen = Application.GetOpenFilename()
'do stuff
End Sub
'----------------------------

Jim Cone
San Francisco, USA


"Ella"
wrote in message
oups.com
I want to create a macro that creates a pop up box that ask the name of
the worksheet i want to open. What statement do i use?
please help :

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

Dim ans as String
Dim sh as Worksheet
ans = InputBox("What is the sheet name?")
if ans = "" then
' user hit cancel
exit sub
end if
On Error Resume Next
set sh = worksheets(ans)
On Error goto 0
if sh is nothing then
msgbox ans & " does not exist"
else
sh.Activate
End if

--
Regards,
Tom Ogilvy

"Ella" wrote in message
oups.com...
I want to create a macro that creates a pop up box that ask the name of
the worksheet i want to open. What statement do i use?
please help :



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default basic


Try this one:


-------------------------------------------------------
Sub Select_Worksheet()

Dim SheetName As String
Dim I As Integer

SheetName = InputBox("Write the name of the Sheet to open")
For I = 1 To Worksheets.Count
If Worksheets(I).Name = SheetName The
Worksheets(SheetName).Activate
Next I

End Sub
-------------------------------------------------------

Please, note that the sheet name is case sensitive in this cod

--
baldomer
-----------------------------------------------------------------------
baldomero's Profile: http://www.excelforum.com/member.php...fo&userid=2568
View this thread: http://www.excelforum.com/showthread.php?threadid=44759

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default basic

Hi Ella,
I like to supply a default when using InputBox, so that you don't have
to necessarily type in anything, in this case a sheetname.

Sub specifysheetname()
Dim response As String
response = Application.Worksheets(1).Name
response = Application.InputBox( _
"Enter the sheetname", _
"Enter sheetname:", response, , , , 1)
If response < "False" Then
On Error Resume Next
Application.Worksheets(response).Activate
If Err.Number = 9 Then MsgBox "no such sheet"
On Error GoTo 0
End If
End Sub

Are you aware that you right click a sheet navigation arrow left
of the sheetnames and select a sheet or "more sheets". Or
a dialog to directly bring up more sheets.
http://www.mvps.org/dmcritchie/excel...htm#moresheets

Sooner or later if you have a lot of sheets you will want to sort the
worksheet tabs.
http://www.mvps.org/dmcritchie/excel...#sortallsheets

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Ella" wrote in message oups.com...
I want to create a macro that creates a pop up box that ask the name of
the worksheet i want to open. What statement do i use?
please help :





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
this is probably very basic justjohn Excel Discussion (Misc queries) 1 January 20th 06 12:11 PM
Basic If Trying To Excel Excel Worksheet Functions 4 December 26th 05 02:10 AM
DV basic help cjtj4700 New Users to Excel 5 December 14th 05 12:57 AM
Need some basic help Babio Excel Programming 1 September 22nd 04 05:38 AM
probably 2 basic joe Excel Programming 0 July 24th 03 02:37 AM


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