tree view + comboboxes

white_flag

Active Member
Joined
Mar 17, 2010
Messages
331
Hello

It is possible to make an treview with comboboxes in excel? via VBA. If Yes can be provide an example. thank you
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Well you could use something like this but are you sure this is what you want?
Code:
Dim rng As Range
Dim I as Long
 
       Set rng = Range("A1:D10")
 
       For I = 1 To 4
               Me.Controls("ComboBox" & I).List = rng.Columns(I).Value
       Next I
 
Upvote 0
Sorry I don't understand what you mean.

What is it exactly you want to do?

Where is your userform, Word?
 
Upvote 0
I have an userform in word with 10 combo. that combos need to be populated from an excel file (from 10 columns A,B,C etc). Then also wen you choose from one combo an "name" the other combos to actualized depends on the row etc ... like this, it is understadable ?
 
Upvote 0
Not quite - why do you need so many comboboxes?

If you want to display multiple columns use a listbox.
 
Upvote 0
because from excel file I just need only some columns not all data. and the columns (that one that I need) are not puted in order (A,B,C.. it is lik D,G,A..etc )
 
Upvote 0
it is something like this:

Code:
Option Explicit
 
Private Sub ComboBox1_Change()
    ComboBox2.ListIndex = ComboBox1.ListIndex
End Sub

Private Sub UserForm_Initialize()
  
  With GetObject("D:\ooo.xls")
    
    ComboBox1.List = .sheets(1).Range("A2:A10").Value
    ComboBox2.List = .sheets(1).Range("B2:B10").Value
    
   .Close False
    
  End With
End Sub
 
Upvote 0
for the moment I let it like this:


Code:
Option Explicit
 
Private Sub ComboBoxA1_Change()
    Dim i As Integer
    For i = 1 To 9
        Controls("ComboBoxA" & i).ListIndex = ComboBoxA1.ListIndex
    Next
End Sub
 
Private Sub ComboBoxA2_Change()
    Dim i As Integer
    For i = 1 To 9
        Controls("ComboBoxA" & i).ListIndex = ComboBoxA2.ListIndex
    Next
End Sub
.
.
.
 
Private Sub from_excel()
  With GetObject("D:\ooo.xls")
        ComboBoxA1.List = .sheets(1).Range("E2:E456").Value
        ComboBoxA2.List = .sheets(1).Range("K2:K456").Value
        ComboBoxA3.List = .sheets(1).Range("W2:W456").Value
        ComboBoxA4.List = .sheets(1).Range("Y2:Y456").Value
        ComboBoxA5.List = .sheets(1).Range("L2:L456").Value
        ComboBoxA6.List = .sheets(1).Range("M2:M456").Value
        ComboBoxA7.List = .sheets(1).Range("P2:P456").Value
        ComboBoxA8.List = .sheets(1).Range("D2:D456").Value
        ComboBoxA9.List = .sheets(1).Range("B2:B456").Value
        .Close False
  End With
End Sub
 
Private Sub UserForm_Initialize()
    from_excel
End Sub
 
---then the code for bookmarks

what do you think?

now I have to fix the last used value from column in excel (A2-A456) to become realistic. You have in ideea?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,903
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top