I'm trying to cycle through a selection of cells and rename those cells based on text values on the spreadsheet.
Sub naming()
Dim cel As Range
Dim selectedRange As Range
Dim to_offset As Integer
Set selectedRange = Application.Selection
Answer = InputBox("Column Where Named Are?")
col_number = Range(Answer & 1).Column
For Each cel In selectedRange.Cells
cel.Name.Delete
to_offset = col_number - cel.Column
cel.Name = cel.Offset(0, to_offset).Value
Next cel
End Sub
The delete command is the problem - so I thought I'd check for names using Len() but get a 1004 error.
If there are no names already defined for the cell it works (but I can't leave the delete code in).
If there are names already defined for the cell it works (and I use the delete).
I need to use the delete for existing names - but have it step over blank names.