User creates new row while autofilter is on

BarcelonaJoe

New Member
Joined
Jan 27, 2012
Messages
4
Hello Excel Experts,

I am new to the forum. Anyway, I have a hard time describing this issue so I'm not sure if it has been posted previously. If you know of a thread, please let me know.

We currently have a workbook where the users can employ selections via column filters. They would use the filters to manage their entries.

They get in trouble when they forget to reset their selections and then add a new row/s. So instead of the next true row being 255, the next row they add might start at 4834. So at times, we get frantic calls about "missing rows" or "duplicate rows" by virtue of the filter selections being on or defaulted.

We are trying to help our users by somehow detecting the filter settings and maybe using an on change event to either warn the user that the filter is being used, or do something else to make sure that the next row added after 254 is 255.

I got a year of VBA experience and 2 .XLSM 2007 workbooks in production to my name. Unfortunately, I can't seem to see a solution for this. I reason that this is a chicken and egg situation--by the time the on change event occurs, the damage has been done (meaning that the row at 4834 already exists).

Anyway, any thoughts would be appreciated.

Thanks,

BarcelonaJoe
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi and welcome to the board.

Have you considered using the Application.Undo Method in the worksheet change event if the filter is being used?
 
Upvote 0
If it is just a visual reminder they need (doesn't stop them doing it)
you could add a command button to the page that changes colour to red when a filter is on, clicking the button will turn all filters off and turn the button green.

Like I said, it is only a visual reminder.

Code:
Private Sub Worksheet_Calculate() 'filter button colours & caption
If ActiveSheet.FilterMode Then
CommandButton1.Caption = "Turn Filters OFF"
CommandButton1.BackColor = RGB(252, 72, 72) 'red
Else:
CommandButton1.Caption = "Filters ok"
CommandButton1.BackColor = RGB(192, 255, 192) 'light green
End If
End Sub

Code:
Private Sub CommandButton1_Click() 'Filter Button Re-Set
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
ActiveSheet.Range("A6").Select 'park the cursor
End Sub
 
Upvote 0
PS - with worksheet calculate(),
you do need to have a calculation on the worksheet, otherwise it will not function
 
Upvote 0
You could also use two formulas provided one of your columns contains values.

This would give you the total for the range

Code:
=SUM(A2:A100)

This would give you the Filtered total.
Code:
=SUBTOTAL(109,A2:A100)

Both totals will be the same until you activate a filter. So you could combine these two in an “IF” statement:-
Code:
=IF(SUM(A2:A100)=SUBTOTAL(109,A2:A100),"Filters are ok","Filters are ON")

Then use conditional formatting to check for “Filters are ON” and select a bright (in ya face) colour.

.
 
Upvote 0
Thanks for the thought, Paul.

Based on your input, I am able to generate a warning for the user when any change is detected while the autofilter selections are on.

My idea is to warn the user early, so that he/she can undo the recent entry, reset the filter, and then continue on with the edit at the next row where the insertion is more appropriate.

I was thinking about automating the undo, but it is much safer to let the user do it.

So things are wrapping up quite nicely. Thanks to Paul and Jaafar for their valuable assistance. :)

BarcelonaJoe
 
Upvote 0

Forum statistics

Threads
1,215,594
Messages
6,125,723
Members
449,255
Latest member
whatdoido

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