• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

Fill a ListBox-control with values from another workbook

I have a combo box (list box) named Vehicle_Type. I would like to get info from workbook C:\Users\Owner\Desktop\Real Indy\FilterApplication.xls  but I will be on another sheet on another workbook.  
0
dave5m
Asked:
dave5m
  • 2
  • 2
1 Solution
 
NorieCommented:
There are various ways this could be done.

1 Use code to extract values from a closed workbook.

2 Open the workbook with the data, then populate the listbox using AddItem.

3 Copy the data to a hidden worksheet in the workbook with the listbox, and then populate in the usual ways eg AddItem, List, named ranges etc.

1 is possible but could be complicated - I must admit most of the code I've seen to get data from a closed workbook has involved only a few values.

Wth 2 &3 you would need to open the workbook, but the user doesn't need to see that happening.

Dim wbData As Workbook
 
Application.ScreenUpdating = False
Application.DisplayAlerts = False
 
'open workbook
 
Set wbData = Workbooks("C:\Users\Owner\Desktop\Real Indy\FilterApplication.xls")
 
' code to populate listbox, what this is depends on at least 2 things - where the listbox located eg worksheet/userform and what type of control it is if the latter. ie worksheet
 
wbData.Close

Open in new window

0
 
dave5mAuthor Commented:
i finally see what you mean.  i'm a little slow.  now one question.  after i want to close the sheet that i copied and pasted using a macro to close a sheet, excel asks me if i want to save the sheet. i do not but, there will be other users using this program and i do not want excel to ask them either.  can i take that message box out?
0
 
NorieCommented:
Well you don't 'close' a worksheet.

You can however close a workbook, as the code does in line 12.

If you add False after Close the user should get no message and the file won't be saved.

If you need to suppress other messages you can use something like this.
Application.DisplayAlerts = False

' your code

Application.DisplayAlerts = True


0
 
dave5mAuthor Commented:
THANK YOU VERY MUCH-SORRY I TOOK SOOOOOOO LONG
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now