I have the following code. I would like to do this same operation for several more rows. I'm sure there has got to be a way to simplify this using some type of loop or variables, but I can't figure it out. What I am doing is pasting copied text into the cell when I click on it, then looking up a cell in the same row that I copied from and pasting this value next to it.
The parts that change I have replaced with X below (x is all the same #)...
Help please!
Code:
If Target.Address = "$E$3" Then
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
FndStr = Cells(3, 5)
Set FndVal = Columns("C").Find(What:=FndStr, LookAt:=xlWhole)
If FndVal Is Nothing Then
MsgBox "No End Time Found"
Else
FndVal.Offset(0, 4).Copy
End If
Cells(3, 6).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End If
If Target.Address = "$E$4" Then
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
FndStr = Cells(4, 5)
Set FndVal = Columns("C").Find(What:=FndStr, LookAt:=xlWhole)
If FndVal Is Nothing Then
MsgBox "No End Time Found"
Else
FndVal.Offset(0, 4).Copy
End If
Cells(4, 6).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End If
Code:
If Target.Address = "$E$X" Then
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
FndStr = Cells(X, 5)
Set FndVal = Columns("C").Find(What:=FndStr, LookAt:=xlWhole)
If FndVal Is Nothing Then
MsgBox "No End Time Found"
Else
'MsgBox FndVal.Offset(0, 6).Value
FndVal.Offset(0, 4).Copy
End If
Cells(X, 6).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End If
Help please!