Having trouble getting a simple script to work. I want to define the contents of columns to the table header name as a defined name.
so that means that if in column A I have a range of data A2:A10 I would want that defined as a name. The name would = A1.
I know the rows may vary with different data sets loaded. I want it to loop from A1 to CA1.
Unsure how to put the Namedef into the loop.
so that means that if in column A I have a range of data A2:A10 I would want that defined as a name. The name would = A1.
I know the rows may vary with different data sets loaded. I want it to loop from A1 to CA1.
Unsure how to put the Namedef into the loop.
Code:
Public Sub NameDef()
Dim NameDef As String
Dim LastRow
LastRow = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For Each NameDef In Worksheets("Sheet1").Range(Cells(1, 1), Cells(LastRow, 74)).Cells
If NameDef IsText = True Then
NameDef.Name = "NameDef"
End If
Next NameDef
End Sub