Hi: I have data in col A and B. I'd like to build a macro that, if it finds the term "trigger" in col A, it copies the data in col B to col C (all in the same row). But, if it doesn't find the term "trigger" in col A, it copies the prior successful data to col C. Here's what I have so far ...
<tbody>
</tbody>
Thank you!
Code:
Sub Data_Copy()
Dim i As Long
Dim myValue As String
Dim LastRow As Long
Dim StartRow As Long
StartRow = 1
LastRow = Range("A" & StartRow).End(xlDown).Row
For i = StartRow To LastRow
myValue = Range("A" & i).Value
If myValue = "Trigger" Then
Range("C" & i).Value = Range("B" & i).Value
Else: Range("C" & i).Value = myValue
End If
Next i
End Sub
Col A | Col B | Col C |
Trigger | Blue | Blue |
Not Trigger | Yellow | Blue |
Not Trigger | Red | Blue |
Trigger | Green | Green |
<tbody>
</tbody>
Thank you!