Im creating a macro that can be run to edit a file. The macro has a form that opens with 8 check boxes( named checkbox1, checkbox2 ect) The idea is to click the check boxes of the categories you want to keep. The categories are on the excel spread sheet in column C. If you do not select the checkbox the whole row should be erased. This is what I have for code. Could be way off.... =)
I know I will have to repeat the code for each checkbox but have just been trying the one for now. It is eraseing all rows.
Any help would be greatly appreciated!
Code:
Private Sub CommandButton1_Click()
Dim firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
Dim cat As String
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
.DisplayPageBreaks = False
firstrow = .UsedRange.Cells(2).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
cat = "Over All"
For Lrow = Lastrow To firstrow Step -1
With .Cells(Lrow, "C")
If Not IsError(.Value) Then
If .Value = cat Then .EntireRow.Delete
End If
End With
Next Lrow
End With
ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
I know I will have to repeat the code for each checkbox but have just been trying the one for now. It is eraseing all rows.
Any help would be greatly appreciated!