Excel VBA determine if ActiveCell is Table Header

JeannetteE

Board Regular
Joined
May 19, 2016
Messages
53
Hi,

"If ActiveCell.ListObject.Header Then"

I want to do something different if the Active Cell is the Header than if it isn't.

I have many tables and the Header Name is different for all of them.

Any help appreciated
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hello, You just need to use intersect:

Code:
    If Not Intersect(ActiveCell, Me.ListObjects("[COLOR=#ff0000]YOURTABLENAME[/COLOR]").HeaderRowRange) Is Nothing Then
        'Active cell is a header
    Else
        'Active cell isn't a header
    End If
 
Last edited:
Upvote 0
Hello, You just need to use intersect:

Code:
    If Not Intersect(ActiveCell, Me.ListObjects("[COLOR=#ff0000]YOURTABLENAME[/COLOR]").HeaderRowRange) Is Nothing Then
        'Active cell is a header
    Else
        'Active cell isn't a header
    End If

Thank you for the response. I'm getting an "Invalid use of me word" Error
 
Upvote 0
Try this.
Code:
Dim lst As ListObject

    Set lst = ActiveCell.ListObject
    
    If lst Is Nothing Then
        MsgBox "Active cell not in table."
    Else
        If Not Intersect(lst.HeaderRowRange, ActiveCell) Is Nothing Then
            MsgBox "Active cell is in table header."
        End If
    End If
 
Upvote 0
Solution

Forum statistics

Threads
1,223,888
Messages
6,175,208
Members
452,618
Latest member
Tam84

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