Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA for opening file/populating combo box with sheet names

Hello again Excel VBA gurus!

I am almost halfway now on my Excel application I'm doing and woul
just like to ask for some help on what I'm supposed to happen once
run my scripts:

1. When the user click a command button, I would like to inquire wha
file he would like to open and put that filename on a variable, lik
when you do a File - Open.
2. Once the file is opened, I would like to populate a combo box or
drop-down list with the names of the sheets on the workbook and plac
on another variable the sheet that the user had chosen so that I ca
use it to determine which sheet will I want my main script to work on.

Last question, on Excel, what is the difference when you use objects o
the Forms toolbox as compared with using the control toolbox?

Thanks as always for your help!
Sinobat

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA for opening file/populating combo box with sheet names

1. Take a look at the GetOpenFileName method, as it allows the user to
select the file. It doesn't open it, just returns the full path which you
can save in a variable.

2. Save the sheet names in a hidden worksheet, and link your combobox to
that range.

Forms controls are maybe easier to use, but control toolbox controls are
more flexible.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Sinobato " wrote in message
...
Hello again Excel VBA gurus!

I am almost halfway now on my Excel application I'm doing and would
just like to ask for some help on what I'm supposed to happen once I
run my scripts:

1. When the user click a command button, I would like to inquire what
file he would like to open and put that filename on a variable, like
when you do a File - Open.
2. Once the file is opened, I would like to populate a combo box or a
drop-down list with the names of the sheets on the workbook and place
on another variable the sheet that the user had chosen so that I can
use it to determine which sheet will I want my main script to work on.

Last question, on Excel, what is the difference when you use objects on
the Forms toolbox as compared with using the control toolbox?

Thanks as always for your help!
Sinobato


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA for opening file/populating combo box with sheet names

Bob,

Thanks for the information! However, can you give me a sample code o
how I can get the sheet names from workbook? I don't have an idea ho
can I iterate through the sheets on the workbook and get the names.

Thanks again!
Sinobat

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA for opening file/populating combo box with sheet names

Hi Sinobato,

Okay, once you have opened the workbook, this code will get the sheet names
and store them in a sheet called Hidden in column A

i=0
For Each sh In Activworkbook.Worksheets
i=i+1
Worksheets("Hidden").Range("A" & i).Value = sh.Name
Next i

To link the combox to the range use


With ActiveSheet.ComboBox1
.ListFillRange = "Hidden!" & "A1:A" & i
.ListIndex = 0
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Sinobato " wrote in message
...
Bob,

Thanks for the information! However, can you give me a sample code of
how I can get the sheet names from workbook? I don't have an idea how
can I iterate through the sheets on the workbook and get the names.

Thanks again!
Sinobato


---
Message posted from http://www.ExcelForum.com/



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
Populating listbox with sheet names johnb Excel Discussion (Misc queries) 1 May 16th 08 12:33 PM
Populating sheet names in combobox Todd Huttenstine[_2_] Excel Programming 3 December 21st 03 12:11 AM
Populating Sheet Data From A UserForm Combo Box Enabled For Multi-Choices R3df1sh[_3_] Excel Programming 1 December 4th 03 08:58 PM
Populating combo boxes Cecilkumara Fernando Excel Programming 3 November 7th 03 02:38 AM
Populating combo box with a function Derek Gadd Excel Programming 5 October 29th 03 10:59 AM


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