PDA

View Full Version : lookup word then apply formula



av8tordude
12-14-2013, 09:40 AM
I have this code that applies a formula to a number I input. If cell is moved, I have to change the code to the cell I moved it to. How can I adjust it to lookup a specific word in column B and then apply the formula? Thank you for your help


Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Cells = Range("D10") Then
Target.Value = Target.Value / "3.65"
End If
Application.EnableEvents = True
End Sub

SamT
12-15-2013, 09:00 AM
Private Sub Worksheet_Change(ByVal Target As Range)

'Check that Target is inside a specific Range
If Not Intersect(Target, Range(("D:D")) Then Exit Sub 'Target not in Column D

'Find a Cell containing a word in Range("B:B")
Dim WordCell As Range
Set WordCell = Columns(2).Find("TheWord", {Find Parameters go here}) 'Returns the first Cell in B:B containing the word

Check if Target is Offset from another Cell
If Not Target Is WordCell.Offset(0, 2) Then Exit Sub 'Is Target in same Row as "TheWord"?

Check if Target is in same Row
If Not Intersect(Target, WordCell.Row) Then Exit Sub

End Sub