Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Allow user to choose worksheet from newly opened file

I have written a macro that performs the same set of commands to a worksheet
for a set of data of a given format.

this data is supplied to me from various sources but is always of the same
format. I want the macro in one excel file to prompt for which file to open
(which I have done using Application.GetOpenFilename) and then prompt the
user for which worksheet should be made active. The names of the sheets are
indicative of what they contain.

So I guess after saying open test.xls I want the user prompted with a list
of the worksheets available in test.xls and allow them to select which
should be made active for the macro to perform its duties.

Any ideas?

Thanks

--
Chris Lewis


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Allow user to choose worksheet from newly opened file

I created a userform, with a combobox and commandbutton, the form is opened
after the GetOpenFileName dialog ends with

UserForm1.Show

In the userform code, the combobox is filled with the names of all sheets in
the activeworkbook, if a valid name is chosen by the user the selected sheet
is activated,. The command closes the userform. Your code could run after
this.

Private Sub ComboBox1_Change()
If ComboBox1.ListIndex = 0 Then
Sheets(ComboBox1.Value).Activate
End If
End Sub

Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
Dim Ws As Worksheet
For Each Ws In ActiveWorkbook.Worksheets
ComboBox1.AddItem Ws.Name
Next
End Sub

--
Cheers
Nigel



"Chris Lewis" wrote in message
...
I have written a macro that performs the same set of commands to a
worksheet for a set of data of a given format.

this data is supplied to me from various sources but is always of the same
format. I want the macro in one excel file to prompt for which file to
open (which I have done using Application.GetOpenFilename) and then prompt
the user for which worksheet should be made active. The names of the
sheets are indicative of what they contain.

So I guess after saying open test.xls I want the user prompted with a
list of the worksheets available in test.xls and allow them to select
which should be made active for the macro to perform its duties.

Any ideas?

Thanks

--
Chris Lewis



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Allow user to choose worksheet from newly opened file


"Nigel" wrote in message
...
I created a userform, with a combobox and commandbutton, the form is
opened after the GetOpenFileName dialog ends with

UserForm1.Show

In the userform code, the combobox is filled with the names of all sheets
in the activeworkbook, if a valid name is chosen by the user the selected
sheet is activated,. The command closes the userform. Your code could
run after this.

Private Sub ComboBox1_Change()
If ComboBox1.ListIndex = 0 Then
Sheets(ComboBox1.Value).Activate
End If
End Sub

Private Sub CommandButton1_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
Dim Ws As Worksheet
For Each Ws In ActiveWorkbook.Worksheets
ComboBox1.AddItem Ws.Name
Next
End Sub

--
Cheers
Nigel



It werks!! Ta muchly!

--
Chris Lewis


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
Newly opened spreadsheet doesn't display in Excel 2007 kwdavids Excel Discussion (Misc queries) 2 June 19th 08 04:39 PM
Need to Query Excel File Opened by Another User Paul Excel Discussion (Misc queries) 0 December 13th 06 05:57 PM
Recording user and date of when a file is opened Linking to specific cells in pivot table Excel Programming 2 July 27th 05 07:46 AM
Close file and run macro from newly opened file Pradip Jain Excel Programming 1 April 23rd 05 11:39 PM
can't save newly opened files Rasoul Khoshravan Excel Discussion (Misc queries) 1 December 9th 04 07:27 AM


All times are GMT +1. The time now is 08:51 PM.

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"