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

I am trying to setup a database/client file for my work and I am looking to
use a listbox or combo box to select the clients name and when selected to
open up their particular workbook.

Thanks Greg


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


Hello Greg,

I prefer to use ComboBoxes with Database applications due to thei
flexibility and built in routines. The macro I have written loads th
Company and its workbook information from two columns on a worksheet
This way editiing stays simple. When the macro runs, it counts th
entries on the worksheet automatically and loads the ComboBox. Ther
are 2 parts to this code the macro and ComboBox_Click() event code.
have included both for you.

__________________________________________________ _______________

'ComboBox Click Event Code

Private Sub ComboBox1_Click()

Dim WkbName As String

If ComboBox1.ListIndex < -1 Then
WkbName = ComboBox1.List(ComboBox1.ListIndex, 1)
Workbooks.Open (WkbName)
End If

End Sub
__________________________________________________ _______________

'Macro - Add a Module to your Project and paste this code in

Public Sub LoadComboBox()

'Set Properties
With ComboBox1
.BoundColumn = 1
.Clear
.ColumnCount = 2
.ColumnHeads = False
.ColumnWidths = "60;0"
.TextColumn = 1
End With

'Load Data into ComboBox from Worksheet Columns A and B
For I = 1 To R
C = I - 1
ColumnA = Worksheets("Sheet1").Cells(I, 1).Value
ColumnB = Worksheets("Sheet1").Cells(I, 2).Value
ComboBox1.AddItem
ComboBox1.Column(0, C) = ColumnA
ComboBox1.Column(1, C) = ColumnB
Next I
'Show First Entry
ComboBox1.ListIndex = 0

End Sub
__________________________________________________ _______________

Hope this helps,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=34582

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Listbox

Greg

First you need to get the data into the combo/listbox. Where is it? I'd
guess you want two columns in your control, one that contains the client's
name and one that contains the name/path of the workbook. See here for how
to populate multicolumn controls
http://www.dicks-blog.com/archives/2...stboxcombobox/

Once you have that, the code to open a workbook is pretty simple

With Me.ListBox1
If .ListIndex -1 Then
Workbooks.Open .List(.ListIndex-1,1)
Unload Me
End If
End With

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

Greg Brow wrote:
I am trying to setup a database/client file for my work and I am
looking to use a listbox or combo box to select the clients name and
when selected to open up their particular workbook.

Thanks Greg



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
listbox B conditional of input in Listbox A Kim K Excel Discussion (Misc queries) 1 October 31st 06 08:27 PM
Multicolumn Listbox and ordinary listbox Ron_D Excel Programming 0 June 4th 04 08:56 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM
Sorting ListBox results or transposing ListBox values to other cells for sorting Rob[_8_] Excel Programming 1 July 9th 03 04:35 AM


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