Private Sub CommandButton1_Click()
Dim x As Long
Dim i As Long
Dim oControl As OLEObject
Dim dSheet As Worksheet
Dim sSheet As Worksheet
Set dSheet = ActiveWorkbook.Worksheets("Data")
Set sSheet = ActiveWorkbook.Worksheets("Start")
dSheet.Copy after:=Sheets(1)
If Not ComboBox1.Value = "" Then
For i = 2 To Sheet3.Cells(2, 1).End(xlDown).Row
If Not Sheet3.Cells(i, 1).Value = ComboBox1.Value Then
Sheet3.Rows(i).EntireRow.Delete
End If
Next i
If Not ComboBox2.Value = "" Then
For i = 2 To Sheet3.Cells(2, 1).End(xlDown).Row
If Not Sheet3.Cells(i, 2).Value = ComboBox2.Value Then
Sheet3.Rows(i).EntireRow.Delete
End If
Next i
End If
If Not ComboBox3.Value = "" Then
For i = 2 To Sheet3.Cells(2, 1).End(xlDown).Row
If Not Sheet3.Cells(i, 3).Value = ComboBox3.Value Then
Sheet3.Rows(i).EntireRow.Delete
End If
Next i
End If
If Not ComboBox4.Value = "" Then
For i = 2 To Sheet3.Cells(2, 1).End(xlDown).Row
If Not Sheet3.Cells(i, 4).Value = ComboBox4.Value Then
Sheet3.Rows(i).EntireRow.Delete
End If
Next i
End If
If Not ComboBox5.Value = "" Then
For i = 2 To Sheet3.Cells(2, 1).End(xlDown).Row
If Not Sheet3.Cells(i, 5).Value = ComboBox5.Value Then
Sheet3.Rows(i).EntireRow.Delete
End If
Next i
End If
For Each oControl In sSheet.OLEObjects
With oControl
If Left(.Name, 3) = "chk" Then
If Not .Object.Value = True Then
For i = 6 To Sheet3.Cells(1, 1).End(xlToRight).Column
If Sheet3.Cells(1, i).Value = .Object.Caption Then
Sheet3.Columns(i).EntireColumn.Delete
End If
Next i
End If
End If
End With
Next oControl
Else
Sheet3.Delete
End If
End Sub