View Single Post
  #2   Report Post  
JE McGimpsey
 
Posts: n/a
Default

One way:

Const sPROMPT As String = "Which Sheet (% max)?"
Dim wb As Workbook
Dim vResult As Variant
Dim nMax As Long
Dim fname As String
fname = Application.GetOpenFilename
Workbooks.Open Filename:=fname
fname = Application.GetOpenFilename
Set wb = Workbooks.Open(Filename:=fname)
nMax = wb.Worksheets.Count
Do
vResult = Application.InputBox( _
Prompt:=Application.Substitute(sPROMPT, "%", nMax), _
Title:="Open " & fname, _
Type:=1, _
Default:=1)
If vResult = False Then Exit Do 'User cancelled
Loop Until vResult = 1 And vResult <= nMax
If IsNumeric(vResult) Then If vResult 0 Then _
wb.Worksheets(vResult).Activate


In article ,
"Jeff" wrote:

Hello,

I have the following VBA Macro:
fname = Application.GetOpenFilename
Workbooks.Open filename:=fname
fname = Application.GetOpenFilename
Set wb = Workbooks.Open(filename:=fname)
fname has 12 worksheets. It is possible to activate any of them with an
inputbox ?
Thanks,