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
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Watch MrExcel Video

Forum statistics

Threads
1,123,042
Messages
5,599,469
Members
414,312
Latest member
mikefire911

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