Visual Basic Code

  • Thread starter Thread starter Glenn Robertson
  • Start date Start date
G

Glenn Robertson

Hi,
I am trying to write some visual basic code behind a macro and I want it to
do the following.

1) Select the whole of coloum C
2) Activate the find box as in (CTRL + F)

Alternativly some code so that I could enter something in cell A1 then click
the macro and it would search coloumn C for the value that is in cell A1.

Many thanks, Glenn
 
If you search VBA Help for: FindMethod
you'll see some examples.

Meanwhile....Here's something to get you started:

Sub UseFind()
Dim vResult
Dim sht As Worksheet
Set sht = ActiveSheet
With sht
Set vResult = .Range("C:C") _
.Find( _
What:=.Range("A1").Value, _
LookAt:=xlPart)
If Not vResult Is Nothing Then
vResult.Select
Else
MsgBox "No match"
End If
End With
End Sub

Is that something you can work with?
Post back if you have more questions.
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)
 
I'd use Ron's technique, but you could just select column C and show the
Edit|Find dialog, too:

Option Explicit
Sub testme01()
With ActiveSheet
.Range("C1").EntireColumn.Select
Application.Dialogs(xlDialogFormulaFind).Show _
arg1:=.Range("a1").Value
End With
End Sub

It won't find the value--it just shows the dialog to the user.
 
Back
Top