Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Actually I would have suggested using the autofilter with the code, but if
you think that will be two slow, then you need to pick it up in an array Assume data on sheet data starting in Cell A1 sizes in column C prices in column E comboboxes/wood selected on sheet Input Sub tester9() Dim varr As Variant, myArray() As Variant Dim sVal As String Dim rng As Range, rng1 As Range, rng2 As Range Dim i As Long, j As Long Dim colSize As Long ' column number containing size Dim colPrice As Long ' column number containing price Dim ncnt As Long With Worksheets("Input") Set rng = .Cells(4, 9).Value 'get wood selection sVal = rng.Value ' or sVal = .combobox1.Value End With colSize = 3 colPrice = 5 With Worksheets("Data") Set rng1 = .Range("A1").CurrentRegion Set rng2 = rng1.Columns(1) ' wood category End With ncnt = Application.CountIf(rng2, sVal) ReDim myArray(1 To ncnt, 1 To 2) varr = rng1.Value j = 0 For i = 2 To UBound(varr, 1) If varr(i, 1).Value = sVal Then j = j + 1 myArray(j, 1) = varr(i, colSize) myArray(j, 2) = varr(i, colPrice) End If Next rng.Parent.combobox2.List = myArray ' or 'Worksheets("Input").combobox2.List = myArray End Sub compiled but not tested -- Regards, Tom Ogilvy "Pierre Cardin" wrote in message ... "I am not sure it totally applicable here. You might need code that does an autofilter on your data and loads the second box with the results. Post back if that is the case. (or you may want to just use an autofilter on your original data since it does what you want by default)." Looks like code is more appropriate. autofilter: Each line on the active sheet has numerous vlookups and if functions imbedded, and crunches up to 2000 items. . it would consume huge resources to use the autofilter each time and refresh the screen with the retrieved data, as well as the time involved. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
checkbox in dropdown question | Excel Worksheet Functions | |||
DropDown Question | Excel Worksheet Functions | |||
Date Dropdown Question | Excel Discussion (Misc queries) | |||
Years of Service Question? | New Users to Excel | |||
Years of Service Question? | New Users to Excel |