Hi Everyone
VBA novice but learning. I have 2 workbooks one called stations and the other services. I would like to use a combo box in services showing the values from column G in stations. Depending on the selection made would then update the values from stations A1 to services C7, stations A3 to services C8 and stations A6 to services C9. There are a few more but Im hoping with a push in the right direction I can manage the rest.
Having problems, can only get values into combo box with both books open.
Any help appreciated.
Regards
brendonh
Last edited by brendonh; 02-11-2012 at 06:22 PM.
You need to open the other workbook, load the combobox then close the other workbook. Hise this by switching off screen updating
Option Explicit Private Sub UserForm_Initialize() Dim oWbk As Workbook Dim rdata As Range Application.ScreenUpdating = False 'check if workbook containing source is open if not open it. If Not WorkbookOpen("P:\Accounts\Billing Schedule.xls") Then Set oWkbk = Workbooks.Open("P:\Accounts\Billing Schedule.xls") Else: Set oWkbk = Workbooks("P:\Accounts\Billing Schedule.xls") End If 'this is the data to load to combobox Set rdata = oWkbk.Worksheets("MASTER SCHEDULE").Range("A5:A103") With Me.ComboBox1 .Clear 'clear any previous data .Style = fmStyleDropDownList .BoundColumn = 0 'set RowSource .RowSource = rdata.Address(external:=True) '0 = no selection .ListIndex = 0 End With Set oWbk = Nothing Set rdata = Nothing Application.ScreenUpdating = True End Sub
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Thanks RoyUK
I have been trying to get this code to work with my workbooks but getting errors. Should this be in a macro module or should the code be in the sheet or workbook?
Regards
brendonh
It's for a combobox on a userform. What kind of combobox are you using & where is it?
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Hi RoyUK
I have a Combo Box from Form Control (now DropDown15) in my services workbook (Sheet1). I can get it to show column G from from the stations workbook (sheet1) by referencing it from the properties Input Range. This is where I start to struggle, once a selection is made eg: Sutherland (from stations workbook, column G row 17). I would like to have this happening in the background but also need to get other values from stations A1 value to services C7, stations A3 value to services C8. As mentioned I'm hoping for a push in the right direction to learn I don't want someone to do it for me.
Regards
brendonh
If you use an ActiveX combobox you can load the whole sheet in workbook 'stations' into that combobox.
Dependent of what you want you can show all data or only some columns. You can make changes in the combobox's values. and when done write those result directly into the workbook 'stations'.
My code will not work with forms comboboxes. You really need to make sure that you give us as much information as possible.
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Thanks RoyUK
I will have another go at it today, fresh start. If I can't get it working I will upload the workbooks.
Regards
Brendon
Hi RoyUK
I have uploaded the workbooks to see if I can get help. Getting the combo box populated is working. From here I want to select a Fire Station in the combo box and populate the text boxes from the row matching the selected depot. The last step would be to transpose the data from the form to the services workbook.
Regards
brendonh
To read more about how to use a userform as a database entryform look here.
See the DatabaseForm
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Thanks RoyUK and snb
Regards
brendonh
Once again thanks to ROYUK and snb for a push in the right direction. The code is now working as I want it to, RoyUK's link was especially helpful.
Regards
brendonh
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks