LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Dropdown from 5 years ago question

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
checkbox in dropdown question Greg Excel Worksheet Functions 2 March 15th 09 11:11 PM
DropDown Question Jim Jackson Excel Worksheet Functions 3 March 16th 07 04:09 PM
Date Dropdown Question Paperback Writer Excel Discussion (Misc queries) 3 November 27th 06 10:21 PM
Years of Service Question? Kane New Users to Excel 2 February 3rd 06 03:05 PM
Years of Service Question? Stefi New Users to Excel 0 February 3rd 06 11:27 AM


All times are GMT +1. The time now is 04:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"