ShowAllData

mt

Board Regular
Joined
Feb 24, 2006
Messages
134
I want to make sure a worksheet is unfiltered before proceeding with the rest of the routine. I can make sure that there is data to unfilter with verifying the last row is = to > than 5, but if the data is already unfiltered, what is the correct syntax to code this. I try to avoid using the "On Error Resume Next" command.

Thanks.
Mike

Code:
With Worksheets("ActualData")
    aRow = Range("A" & Rows.Count).End(xlUp)
        If aRow >= 5 And .ShowAllData = False Then
            .ShowAllData
        End If
    End With
[code]
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
I must admit it's something that I do almost automatically when I create a VBA project, especially where users have the ability to access and filter data before running the macro. I would generally create the macro with workbook and worksheet object parameters and unfilter any sheet that may potentially be filtered.

I've lost too much data using .End(xlUp) that finds the last visible row of data rather than the last populated row and overwritten existing data instead of going to the next available row!
 
Upvote 0
Re: ShowAllData - Department of Redundancy Department?

Sorry to wake this thread up 7 years later, but isn't this:

Code:
With Worksheets("ActualData")
    If .AutoFilterMode Then
        If .FilterMode Then
            .ShowAllData
        End If
    Else
        If .FilterMode Then
            .ShowAllData
        End If
    End If
End With


The same as this?


Code:
With Worksheets("ActualData")
    If .FilterMode Then
        .ShowAllData
    End If
End With


AutoFilterMode is a boolean that can only be True or False. The first version checks FilterMode no matter what AutoFilterMode is set to. The second version also checks FilterMode no matter what AutoFilterMode is set to.

Am I missing something?


Thanks,

Greg
 
Upvote 0
Since we're waking up old threads, yes GJL I think you're right. .AutoFilterMode is only concerned with the dropdown filter arrows, .FilterMode is what really matters for .ShowAllData. The end result can be accomplished in one line:

Code:
If Sheet1.FilterMode Then Sheet1.ShowAllData
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

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