Column navigation by headers

teodormircea

Active Member
Joined
Jan 8, 2008
Messages
331
Hello Forum,

I'd like to know if there is a possibility to go directly to a column in a sheet by the header name.

If a have the column serial i , the macro will point me directly to this column.

Thanks.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi

You could identify the column header by using the Find method eg:

Code:
Dim rng As Range
Set rng = Activesheet.Rang("1:1").Find("YourHeaderNameHere")
 
If Not rng Is Nothing Then rng.Select
 
Upvote 0
Thanks but is giving me an error, on this line
Set rng = ActiveSheet.Rang("1:1").Find("TEST"), it doesn't support the property or method
 
Upvote 0
Hello again , i have a problem with this method,

if i have in a sheet 2 columns that have :OCOST and NCOST column's header, this macro doesn't make the difference between them .
 
Upvote 0
Found a new approach
Private Sub CommandButton18_Click()
Dim FindString As String
Dim Rng As Range
FindString = "COSTCTR"
If Trim(FindString) <> "" Then
With ActiveSheet.Range("1:1")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
Else
MsgBox "Nothing found"
End If
End With
End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,449
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top