I am using the following code to copy data from one cell to another. The challenge I am having is with with the definition of the if condition as a partial match: The cells in column A contain information in the following format: RANDOM_TEXT_25DP.
I need to copy data whenever cell A contains _25DP at the end. How do I do that?
Current code
I need to copy data whenever cell A contains _25DP at the end. How do I do that?
Current code
VBA Code:
Sub MoveData()
Dim k As Integer, kMove As Integer
Dim Kcolumn As Long, Ccolumn As Long
Dim refCell As Range, outputCell As Range
Kcolumn = 7 ' destination
Ccolumn = 6 ' reference
For k = 2 To 5000
If Cells(k, 1) = "_25DP" Then
kMove = k -1
Set refCell = Cells(k, Ccolumn)
Set outputCell = Cells(kMove, Kcolumn)
outputCell.Value = refCell.Value
End If
Next k
End Sub