selection change event within a column of a table

saurab8

New Member
Joined
Jun 21, 2019
Messages
9
hi there,

I have been trying to figure this one out but no combiation seems to be working.

I have a table, called "ALLOCATION" in a sheet "RAW_DATA".
I want to trigger another marco when a empty cell of column "DATE" is selected of the able table.

I am using Excel 2016.

Macro that I wrote works, but it works for the whole column not just within the table.
I hope someone could help me out.

Kind regards
Saurabh
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Welcome to MrExcel forums.

Try this code in the "RAW_DATA" sheet module:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Dim table As ListObject
    
    Set table = ActiveSheet.ListObjects("ALLOCATION")
    
    If Not Intersect(Target, table.ListColumns("DATE").DataBodyRange) Is Nothing Then
        If IsEmpty(Target.Value) Then
            Clicked_Empty_Date_Cell table, Target
        End If
    End If
    
End Sub
And this in a standard module:
Code:
Public Sub Clicked_Empty_Date_Cell(table As ListObject, dateCell As Range)

    MsgBox "DATE cell " & dateCell.Address(0, 0) & " in table " & table.Name & " is empty"
    
End Sub
 
Upvote 0
Thank John_W for your help. The problem is fully solved. Really appreciate your help.

I wanted to add multiple rows in the table, but the sheet is protected. Above gave me an option to unprotect and protect the sheet, depending which cell is selected.

Cheers :)
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,238
Members
448,555
Latest member
RobertJones1986

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