Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Default Adding a VLookup to an AutoComplete ComboBox

I am using a function that generates an activex combobox to provide an autocomplete capability on top of the data validation.

I want to add a vlookup, so that the selected entry gets looked up in a table, and the result is what eventually fills the cell.

I cant figure out where to put my vlookup function.

any ideas?

Function I want to use (not even sure how to reference the combobox value)

WorksheetFunction.VLookup((???), "D5:E749", 2, False)

Macro for combo box:


'==========================
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim str As String
Dim cboTemp As OLEObject
Dim ws As Worksheet
Set ws = ActiveSheet
Cancel = True
Set cboTemp = ws.OLEObjects("TempCombo")
On Error Resume Next
With cboTemp
'clear and hide the combo box
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With

On Error GoTo errHandler
If Target.Validation.Type = 3 Then
'if the cell contains a data validation list
Application.EnableEvents = False
'get the data validation formula
str = Target.Validation.Formula1
str = Right(str, Len(str) - 1)

With cboTemp
'show the combobox with the list
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 5
.Height = Target.Height + 5
.ListFillRange = ws.Range(str).Address
.LinkedCell = Target.Address

End With
cboTemp.Activate
'open the drop down list automatically
Me.TempCombo.DropDown

End If

errHandler:
Application.EnableEvents = True
Exit Sub

End Sub
Reply
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
adding ComboBox programitacally greg Excel Programming 2 June 18th 07 09:02 PM
Data Validation Combobox w/autocomplete tamee Excel Discussion (Misc queries) 2 April 10th 07 12:42 PM
AutoComplete - Forms Combobox Sige Excel Worksheet Functions 2 November 30th 05 09:17 AM
Adding to AutoComplete programmatically Jim McLeod Excel Programming 3 April 19th 04 05:29 PM
3 possible methods for adding value to a combobox Todd Huttenstine[_3_] Excel Programming 3 January 25th 04 01:16 AM


All times are GMT +1. The time now is 12:45 AM.

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

About Us

"It's about Microsoft Excel"