Choose Selection from User Dialog

timmytonga

New Member
Joined
Sep 23, 2011
Messages
21
Hello,

I need to make a dialog after I open a sheet so the user is only looking at the info that pertains to them. There is a column that categorizes the row into 1 of 14 categories. I want to delete every row that does not pertain to the user some users have multiple categories and some just have 1

The reason for the delete is file size and row count is enormous.

So far I have the code open the file from a drive and then save it to the users desktop. Then I wanted the dialog where the user would select the categories need.
then I was thinking along the lines of using an autofilter to filter on every category the user did not select and than doing the below code but if any one has a different or better idea I am all ears.

I am not sure how to do a dialog where the user can choose which categories they need either.





' looks to make sure the not selected exists

Dim Lastrow As Long


Lastrow = Cells(Rows.Count, 1).End(xlUp).Row
Columns("O:O").Select
Set cell = Selection.Find(What:=????(nonpertaining categories) , After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)


If cell Is Nothing Then

' deletes the not selected


Else
With Range("A1")
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilter.Range.AutoFilter
.AutoFilter Field:=15, Criteria1:=(nonpertaining categories)
Range("A2:A" & Lastrow).SpecialCells(xlCellTypeVisible).EntireRow.Delete
.AutoFilter
End With
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,223,275
Messages
6,171,123
Members
452,381
Latest member
Nova88

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