Here is my code:
Dim X As Long, Index As Long, Word As String
Word = "I-BUTANE"
If Len(Word) Then
For X = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If UCase(Trim(Cells(X, "A").Value)) = UCase(Word) Then
Index = Index + 1
Rows(X).Name = Word & Index
End If
Next
End If
I have a column filled with various chemicals. The order changes, but each chemical will repeat itself ten times. Whenever a row contains "I-BUTANE" in the first column, the entire row will be labeled "I-BUTANE#," where # changes with each appearance (first time you see I-BUTANE, the row is labeled I-BUTANE1).
I keep getting an error when I run my code for all the chemicals that contain a "-" in it. I am assuming Excel does not consider this to be a string.
Does this help?