Deleting table column not counting as a change in range

Fudging

New Member
Joined
Aug 26, 2022
Messages
16
Office Version
  1. 365
Platform
  1. Windows
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim ws As Worksheet
    Dim tableRange As Range

    ' Set the worksheet
    Set ws = Me ' Refers to the current worksheet

    ' Get the range of the table
    Set tableRange = ws.ListObjects("ABC").Range

    ' Check if the changed range
    If Not Intersect(Target, tableRange) Is Nothing Then
        SplitUniqueValues
    End If
End Sub

I have the code posted here that checks if any changes have been made to a table named "ABC, if so, call the "SplitUniqueValues" function. For context, "SplitUniqueValues" converts the table "ABC" to an array and pastes all unique values into a cell. Anyway, this all works just fine until I decide to delete a table column, for some reason, the cell doesn't update with the changes, as in the deleted entries from that column remain in the cell. I assume it doesn't track the "Delete" > "Columns" as a change?

Anyone know what's the issue here?

Ty :)
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim ws As Worksheet
    Dim tableRange As Range

    ' Set the worksheet
    Set ws = Me ' Refers to the current worksheet

    ' Get the range of the table
    Set tableRange = ws.ListObjects("ABC").Range

    ' Check if the changed range
    If Not Intersect(Target, tableRange) Is Nothing Then
        SplitUniqueValues
    End If
End Sub

I have the code posted here that checks if any changes have been made to a table named "ABC, if so, call the "SplitUniqueValues" function. For context, "SplitUniqueValues" converts the table "ABC" to an array and pastes all unique values into a cell. Anyway, this all works just fine until I decide to delete a table column, for some reason, the cell doesn't update with the changes, as in the deleted entries from that column remain in the cell. I assume it doesn't track the "Delete" > "Columns" as a change?

Anyone know what's the issue here?

Ty :)

I've put this formula into a cell and it recalculates whenever there is any change to the values in the table.

=TEXTJOIN(" ",TRUE,UNIQUE(TOCOL(ABC)))
 
Upvote 0
I've put this formula into a cell and it recalculates whenever there is any change to the values in the table.

=TEXTJOIN(" ",TRUE,UNIQUE(TOCOL(ABC)))
Hey, thanks for your answer. I have an issue with the following approach, I should have mentioned that subroutine "SplitUniqueValues" doesn't just paste all unique entries in one cell, it's rather 2 cells based on the entry (for example table ABC contains entries that are either a name or a date) so it will separate names in one cell and dates in the other. Would there be any other solutions?
 
Upvote 0

Forum statistics

Threads
1,223,101
Messages
6,170,116
Members
452,302
Latest member
TaMere

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