Hello
Was trying to create a Procedure to Call Header Name and it Column position
Got stuck as I could not put together to get the column Reference of Column Header Name.
In module
Call HeaderNameColPosName("Header9")
Call ColPosof(“Header9”)
What needs to be coded for Exact Col pos of ColHeader to derive it succesffuly to get the correct Column Reference when procedure called for “Header9” like above
I need to call another procedure for the Column Reference for above
So when
Call ColPosof(“Header9”)
I should get as colPosofHeader9.Column
And then I can utilise wherever required like below
For eg
as wsRng.Columns(ColPosofHeader9.Column).Address(0,0)
Your help will be highly appreciated
Thanks SamD
88
Was trying to create a Procedure to Call Header Name and it Column position
Got stuck as I could not put together to get the column Reference of Column Header Name.
In module
Call HeaderNameColPosName("Header9")
Call ColPosof(“Header9”)
What needs to be coded for Exact Col pos of ColHeader to derive it succesffuly to get the correct Column Reference when procedure called for “Header9” like above
I need to call another procedure for the Column Reference for above
So when
Call ColPosof(“Header9”)
I should get as colPosofHeader9.Column
And then I can utilise wherever required like below
For eg
as wsRng.Columns(ColPosofHeader9.Column).Address(0,0)
VBA Code:
Private Sub HeaderNameColPosName(SrchHeaderName As String)
Dim SrchtxtHeaderName As String
Dim ColFindHeaderName As Range
Public ColNamePos As String
Dim ColumnLetter As String
With Worksheets("Sheet1").Range("A1:J1")
SrchtxtHeaderName = SrchHeaderName
Set ColFindHeaderName = .Find(What:=SrchtxtHeaderName, LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
ColumnLetter = Replace(Cells(1, ColFindHeaderName.Column).Address(0, 0), 1, "")
ColNamePos = ColumnLetter
‘’’’ MsgBox SrchHeaderName & " is with Col.Name " & ColNamePos
End With
End Sub
Your help will be highly appreciated
Thanks SamD
88