R
Ronny
I get the following error when I run this code:
-----
Error:
Run-time error '1004':
That name is not valid.
-----
Code:
Dim lastrow As Long
Dim row_index As Long
For row_index = lastrow - 1 To 1 Step -1
If Left(Cells(row_index, "D").Value, 4) <> Left
(Cells(row_index + 1, "D").Value, 4) Then
Cells(row_index + 1, "D").Resize(2,
1).EntireRow.Insert (xlShiftDown)
Cells(row_index + 1, "C").FormulaR1C1
= "=SUMPRODUCT(--(LEFT(R1C4:R[-1]C4,4)=LEFT(R[-1]
C4,4)),R1C3:R[-1]C3)"
Cells(row_index + 1, "C").Font.ColorIndex = 3
Cells(row_index + 1, "C").Font.Bold = True
Cells(row_index + 1, "C").Font.Size = 14
Cells(row_index + 1, "C").Name = Left(Cells
(row_index, "D").Value, 4)
End If
Next
Debugging points to the last line in the for loop (naming
the cell using the first four characters from the cell
above.)
Thanks in advance!
-----
Error:
Run-time error '1004':
That name is not valid.
-----
Code:
Dim lastrow As Long
Dim row_index As Long
For row_index = lastrow - 1 To 1 Step -1
If Left(Cells(row_index, "D").Value, 4) <> Left
(Cells(row_index + 1, "D").Value, 4) Then
Cells(row_index + 1, "D").Resize(2,
1).EntireRow.Insert (xlShiftDown)
Cells(row_index + 1, "C").FormulaR1C1
= "=SUMPRODUCT(--(LEFT(R1C4:R[-1]C4,4)=LEFT(R[-1]
C4,4)),R1C3:R[-1]C3)"
Cells(row_index + 1, "C").Font.ColorIndex = 3
Cells(row_index + 1, "C").Font.Bold = True
Cells(row_index + 1, "C").Font.Size = 14
Cells(row_index + 1, "C").Name = Left(Cells
(row_index, "D").Value, 4)
End If
Next
Debugging points to the last line in the for loop (naming
the cell using the first four characters from the cell
above.)
Thanks in advance!