View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
BrianB BrianB is offline
external usenet poster
 
Posts: 1
Default Using VBA code when searching in a spreadsheet

Try this :-



Code
-------------------
Private Sub CommandButton1_Click()
Dim foundcell As Object
Dim Col As Integer
'-----------------------------
If ComboBox1.Value < "" Then
myvalue = ComboBox1.Value
Col = 1
ElseIf ComboBox2.Value < "" Then
myvalue = ComboBox2.Value
Col = 2
ElseIf ComboBox3.Value < "" Then
myvalue = ComboBox3.Value
Col = 3
Else
MsgBox ("No entry made")
Exit Sub
End If
'--------------------------
Set foundcell = ActiveSheet.Columns(Col).Find(myvalue)
If foundcell Is Nothing Then
MsgBox ("Not found.")
Else
foundcell.Select
End If
End Sub

-------------------


--
Message posted from http://www.ExcelForum.com