Reputation: 11
This macro is supposed to check the cell value in column A first. Then, if the cell value is not equal to the row number - 2, it should input a set of 2 blank cells. After, it should set the cell in column A equal to row number -2 and set the cell in column B equal to 100%. What happens with my code is instead of doing this everytime it happens, it only does it to the last cell in the given range.
Sub defaultValues()
Dim rowPosition As Long
Dim columnPosition As Long
Dim counter As Long
rowPosition = 3
columnPosition = 1
counter = 3
For Each cCell In Range("A3,A18")
cCell.Select
If ActiveCell.Value <> ActiveCell.row - 2 Then
Range(ActiveCell, ActiveCell.Offset(0, 1)).Insert Shift:=xlShiftDown
ActiveCell.Value = ActiveCell.row - 2
ActiveCell.Offset(0, 1) = "100%"
End If
Next cCell
End Sub
Example Data Set, where the number 5 is missing so cells should be inserted and given the value 5 and 100%
CellNum-2 % 1 93.55% 2 93.38% 3 93.52% 4 95.75% 6 98.66% 7 98.34% 8 98.34% 9 96.08%
Thanks for any help that can be given
Upvotes: 1
Views: 165