Excel VBA Macro To Create List Names or Range Names with Column Headings as they refers List Names for Respective Columns
Sub ColHeaderAsList()
Dim X As Long
Dim Y As Long
On Error Resume Next
Y = ActiveSheet.Columns.Count
For X = 1 To Y 'You can reduce this loop size as you wish
If Cells(1, X) <> "" Then Cells(1, X).EntireColumn.Select
Selection.Name = Cells(1, X).value
Next X
MsgBox "List Names are Created With Columns Headings", , "Successfull !!!"
End Sub
Example:
Sample Data
Output :
List Names / Range Names
Sub ColHeaderAsList()
Dim X As Long
Dim Y As Long
On Error Resume Next
Y = ActiveSheet.Columns.Count
For X = 1 To Y 'You can reduce this loop size as you wish
If Cells(1, X) <> "" Then Cells(1, X).EntireColumn.Select
Selection.Name = Cells(1, X).value
Next X
MsgBox "List Names are Created With Columns Headings", , "Successfull !!!"
End Sub
Example:
Sample Data
Output :
List Names / Range Names
Regards,TAMATAM
No comments:
Post a Comment
Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.