AriffChowdhury
New Member
- Joined
- Jul 28, 2013
- Messages
- 10
I have a macro that does the following;
It copies the header name but i want that to copy COLUMN NAME Like "COLUMN A","COLULMN B","COLUMN C" and so on...
Thank you!
Code:
Sub CreateHeaders()
Dim wsData As Worksheet
Dim wsHeaders As Worksheet
Dim headerRange As Range
Dim header As Range
Dim i As Long: i = 0
Dim anchor As Range
Dim subAddr As String
Set wsData = Worksheets("Sheet1")
Set wsHeaders = Worksheets("Sheet2")
Set headerRange = wsData.Range("A1", wsData.Range("A1").End(xlToRight))
Set anchor = wsHeaders.Range("B5") '## begin inserting the hyperlinks at B5
For Each header In headerRange '## iterate over each cell in the header row
subAddr = "'" & wsData.Name & "'!" & header.Address
With wsHeaders
.Hyperlinks.Add anchor:=anchor, Address:="", SubAddress:= _
subAddr, TextToDisplay:=header.Value
End With
i = i + 1
Set anchor = anchor.Offset(1, 0) '## increment the location of the next hyperlink, to the next row
Next
End Sub
It copies the header name but i want that to copy COLUMN NAME Like "COLUMN A","COLULMN B","COLUMN C" and so on...
Thank you!