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
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