View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Anand Anand is offline
external usenet poster
 
Posts: 13
Default preselecting in combo box

On May 22, 4:43 pm, merjet wrote:
Modify the loop like this:

For Each c In ComboBox1.List
iCt = iCt + 1
If CInt(c) = Range("B11") Then
ComboBox1.ListIndex = iCt
Exit Sub
End If
Next c

Be careful about types. When I fill the List with numbers, they are
taken as Text.

Hth,
Merjet


Now I want to create this as function say, prefillComboBox(cbox as
Object, ValRg as Range, matchVal as string).
However, I'm not sure how I can use the range passed through this
function inside the function. the Range() method does not work with
the ValRg parameter.
Appreciate any help.

thanks,
Anand.