Need Find and color row macro

G

Guest

Hi All.........
I am in need of a macro beyond my skill level, if someone please. I want to
do a FIND on column A and have a pop-up ask the user for a number to find,
then find it and color the whole row gold, then goto column A of that
row..........my efforts at recording brings in specific cell locations which
will not work for multiple searches.

Here's my recorded macro.......
Sub FindVendorNumber()
Columns("A:A").Select
Selection.Find(What:="a01309", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Rows("781:781").Select
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Range("A781").Select
End Sub

Any help would be much appreciated.........

Vaya con Dios,
Chuck, CABGx3
 
B

Bob Phillips

Sub FindVendorNumber()
Dim oCell As Range
Dim val

val = InputBox("Please supply number")
If val <> "" Then
Set oCell = Columns("A:A").Find(What:=val, _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not oCell Is Nothing Then
With oCell.EntireRow.Interior
.ColorIndex = 40
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
oCell.Select
End If
End If

End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
G

Guest

Many thanks Bob, but I get a "1004" error "Unable to get the Find Property of
the Range Calss".... on the "Set oCell" line.....I forgot to mention I'm
using XL97, could that be the problem?

Vaya con Dios,
Chuck, CABGx3
 
G

Guest

I found it!................just needed to add a line,

Sheets("DETAIL").Select......dunno why, but it works fine with that.

Life if good now, and I thank you very very much, kind Sir.

Vaya con Dios,
Chuck, CABGx3
 
G

Guest

CLR said:
Hi All.........
I am in need of a macro beyond my skill level, if someone please. I want to
do a FIND on column A and have a pop-up ask the user for a number to find,
then find it and color the whole row gold, then goto column A of that
row..........my efforts at recording brings in specific cell locations which
will not work for multiple searches.

Here's my recorded macro.......
Sub FindVendorNumber()
Columns("A:A").Select
Selection.Find(What:="a01309", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Rows("781:781").Select
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Range("A781").Select
End Sub

Any help would be much appreciated.........

Vaya con Dios,
Chuck, CABGx3
 
G

Guest

CLR said:
Hi All.........
I am in need of a macro beyond my skill level, if someone please. I want to
do a FIND on column A and have a pop-up ask the user for a number to find,
then find it and color the whole row gold, then goto column A of that
row..........my efforts at recording brings in specific cell locations which
will not work for multiple searches.

Here's my recorded macro.......
Sub FindVendorNumber()
Columns("A:A").Select
Selection.Find(What:="a01309", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
Rows("781:781").Select
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Range("A781").Select
End Sub

Any help would be much appreciated.........

Vaya con Dios,
Chuck, CABGx3
 
Z

Zone

I can't tell if this thread has been answered or not. The quick answer is
to assign the results of the search to a range object
Dim c as range
c=Selection.Find 'and so forth
then you can get the row from c:
myRow=c.Row
James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top