How to find a cell in a macro..

Closed
Report
-
Posts
365
Registration date
Monday February 7, 2011
Status
Contributor
Last seen
September 30, 2013
-
Hello,


I am creating a macro and what i want to to do is to find the word "Tylenol" and then go to the cell beside it and i want to put a formula. Everytime i do a find and then i go to the cell next to it and do my calculation. however, excel is just copying the name of the cell ex. D47 and is totally ignoring the search i did.

what should i do?



Thanks,

1 reply

Posts
365
Registration date
Monday February 7, 2011
Status
Contributor
Last seen
September 30, 2013
120
Use this code, it will helps you

Sub Test()
    Dim cell, Rng As Range
    Set Rng = Range("A1:K" & Cells(Rows.Count, 1).End(xlUp).Row) ' Set your range    
    For Each Cell In Rng
        If cell.Value = "Tylenol" Then
           cell.offset(0,1).formula = "your Formula" ' put your formula
            End If
            Next Cell
End Sub