#1   Report Post  
Jeff
 
Posts: n/a
Default Worksheet.activate

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,

  #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,

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



All times are GMT +1. The time now is 12:13 AM.

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"