PDA

View Full Version : Fill multiple comboboxes from same range variable



HimanshuK
06-28-2016, 11:39 PM
Hi I am using the same range variable to fill multiple comboboxes.

I have placed the range variable code in module as below-

Option Explicit
Public dyrange As Range




Public Sub poplist()


Dim lastrow As Long


Dim dy_range As Name
Dim sht As Worksheet
Set sht = Worksheets("BG")
With sht
lastrow = .Range("E6").SpecialCells(xlCellTypeLastCell).Row
Set dyrange = .Range("E6:E" & lastrow)
End With


End Sub



The combobox change event code in input sheet as below-


Private Sub ComboBox1_Change()


ComboBox1.List = dyrange.Value

End Sub




Private Sub ComboBox2_Change()


ComboBox2.List = dyrange.Value


End Sub


Private Sub ComboBox3_Change()


ComboBox3.List = dyrange.Value


End Sub


But each time I select any one value in combobox 1. it gets same value for combobox 2 and 3. I am using excel 2013 (64- bit).

How do i correct this? I want to use the same listfill range and have select different items in different comboboxes

snb
06-29-2016, 02:41 AM
Please use code tags around VBA code !

The besta advice: start here: Excel VBA Programming For Dummies by John Walkenbach | 9781119077398 | Paperback | Barnes & Noble (http://www.barnesandnoble.com/w/excel-vba-programming-for-dummies-john-walkenbach/1101874584)