Norie advised not to select or activate cells but I don't know how to offset from the activecell as in my following code.
The script looks for values in column D, if it finds the value it offsets the value from column A to another cell.
The script looks for values in column D, if it finds the value it offsets the value from column A to another cell.
Code:
Sub Process1()
Application.Calculation = xlCalculationManual
Range("D2").Select
ActiveCell.Offset(0, -1).Select
Cells(65535, ActiveCell.Column).Select
Range(Selection, Selection.End(xlUp)).Select
ActiveCell.Select
ActiveCell.Offset(0, 1).Select
Set BottomCell = ActiveCell
Set TOPCELL = Cells(2, ActiveCell.Column)
Range(TOPCELL, BottomCell).Select
Dim Cell As Range
For Each Cell In Selection.Cells
If Cell.HasFormula = False Then
End If
If ActiveCell.Value = 2 Then
ActiveCell.Offset(-1, 1).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 3 Then
ActiveCell.Offset(-2, 2).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 4 Then
ActiveCell.Offset(-3, 3).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 5 Then
ActiveCell.Offset(-4, 4).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 6 Then
ActiveCell.Offset(-5, 5).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 7 Then
ActiveCell.Offset(-6, 6).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 8 Then
ActiveCell.Offset(-7, 7).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 9 Then
ActiveCell.Offset(-8, 8).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 10 Then
ActiveCell.Offset(-9, 9).Value = ActiveCell.Offset(0, -3).Value
End If
If ActiveCell.Value = 11 Then
ActiveCell.Offset(-10, 10).Value = ActiveCell.Offset(0, -3).Value
End If
ActiveCell.Offset(1, 0).Select
Next
Application.Calculation = xlCalculationAutomatic
End Sub