Reference column by header?

sramsay

Board Regular
Joined
Feb 19, 2015
Messages
96
I have this code to show a cell’s contents as a message box when double clicked.
It points to Column CE, however this changes frequently.

Is it possible to have the formula point the column based on the header rather than specifying the actual row?



Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("CE10:CE1000")) Is Nothing Then
    If Target.Cells.count = 1 Then
        If UCase(Target.Value) = UCase("No issues reported") Then
            If MsgBox("No issues reported" & vbNewLine & vbNewLine & "Comments must be added on the 'On going issues' sheet", vbOKOnly) = vbOK Then
                Call offsetCell
                Exit Sub
            End If
            Else
            MsgBox Target.Value
            Call offsetCell
        End If
    End If
End If
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,550
Messages
5,832,423
Members
430,132
Latest member
Bdesai

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
Top