Search macro

B

Benoit

Hello,

I would like to create a macro that will search an entire
worksheet for some values and if they find it, to put
a "1" in a designated cell.

EXAMPLE:
=========
A1: 555222
A2: 555222
A3: 555333
A4: 555333
A5: 555444
A6: 555444

I would like the macro to search for "555222", "555333"
and "555444" and when/if it finds smething, to go in
colum B and insert the "1".

I want the Macro to repeat this step for every number
("555222", "555333" and "555444") until he doesn't find
any anymore.

Thanks!!!
 
F

Frank Kabel

Hi
try the following:
Sub search_rows()
Dim RowNdx As Long
Dim LastRow As Long
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
For RowNdx = 1 to lastrow
with Cells(RowNdx, "A").
If .Value = 555222 or . value = 555333 _
or .value = 555444 Then
.offset(0,1).value = 1
End If
end with
Next RowNdx

End Sub
 
L

laprosa

26/11/05

Line Fournier essaye de vous rejoindre. Vous pouvez me contacter a
(e-mail address removed) pour ses details
 

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

Similar Threads


Top