Originally Posted by
Teeroy
You are trying to test the radio button object, what you need is to test the .value property of the object. Also you're checking for a blank worksheet in each radio button option; just do it once at the beginning. Check the following changes to CommandButton2_Click. I've added in one error check so you can get the idea and add your own.
I'm not going to change the style of the programming since it is homework.
[vba]Private Sub CommandButton2_Click()
'Make Sheet2 Active
Sheets(2).Activate
'First check for empty worksheet
If WorksheetFunction.CountA(ActiveSheet.Cells) = 0 Then Exit Sub
'Next check that an order has been entered
last4entries = Join(Application.Transpose(Range("D" & Rows.Count).End(xlUp).Offset(-3, 0).Resize(4, 1)), ",")
If last4entries <> Join(Array("Akron", "Fort Wayne", "Rockford", "Saint Louis"), ",") Then
MsgBox "An order must be entered before it is assigned to a plant"
Exit Sub
End If
'Akron Selection Clear others
If akron.Value Then
x = ActiveSheet.Cells.Find("*", [A1], xlFormulas, xlPart, _
xlByRows, xlPrevious, False, False).Row
'delete last row, Row above last, row above that
ActiveSheet.Cells(x, 1).EntireRow.Delete
ActiveSheet.Cells(x - 1, 1).EntireRow.Delete
ActiveSheet.Cells(x - 2, 1).EntireRow.Delete
End If
'Ftwayne selection Clear others
If ftwayne.Value Then
x = ActiveSheet.Cells.Find("*", [A1], xlFormulas, xlPart, _
xlByRows, xlPrevious, False, False).Row
'delete last row, Row above last, row above that
ActiveSheet.Cells(x, 1).EntireRow.Delete
ActiveSheet.Cells(x - 1, 1).EntireRow.Delete
ActiveSheet.Cells(x - 3, 1).EntireRow.Delete
End If
'Rockfor selection clear others
If rockford.Value Then
x = ActiveSheet.Cells.Find("*", [A1], xlFormulas, xlPart, _
xlByRows, xlPrevious, False, False).Row
MsgBox x 'TESTING ONLY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'delete last row, Row above last, row above that
ActiveSheet.Cells(x, 1).EntireRow.Delete
ActiveSheet.Cells(x - 2, 1).EntireRow.Delete
ActiveSheet.Cells(x - 3, 1).EntireRow.Delete
End If
'stlouis selection clear others
If stlouis.Value Then
x = ActiveSheet.Cells.Find("*", [A1], xlFormulas, xlPart, _
xlByRows, xlPrevious, False, False).Row
'delete last row, Row above last, row above that
ActiveSheet.Cells(x - 1, 1).EntireRow.Delete
ActiveSheet.Cells(x - 2, 1).EntireRow.Delete
ActiveSheet.Cells(x - 3, 1).EntireRow.Delete
End If
End Sub
[/vba]