nepotist
04-22-2009, 12:13 PM
hello guys ,
I am designing a custom ribbon for my application and here is my code Sub FacilityType_Change(control As IRibbonControl, text As String)
Dim Rw As Integer
Dim F As Integer
Worksheets("Report").Activate
Rw = ActiveSheet.Cells(Rows.Count, "d").end(xlUp).Rows
If text = "All Facilities" Then
Cells.Select
Range("E1").Activate
Selection.EntireRow.Hidden = False
If text = "SIS Facilities" Then
Cells.Select
Range("E1").Activate
Selection.EntireRow.Hidden = False
F = 1
For Rw = Rw To 3 Step -1
If Cells(Rw, 3).Value <> F Then
Cells(Rw, 3).EntireRow.Hidden = True
Next Rw
ElseIf text = "Arterial Facilities" Then
Cells.Select
Range("E1").Activate
Selection.EntireRow.Hidden = False
F = 3
For Rw = Rw To 3 Step -1
If Cells(Rw, 3).Value <> F Then
Cells(Rw, 3).EntireRow.Hidden = True
Next Rw
End If
End Sub
when I run it , I get an error Next with out For ,,
Guess I cannot use a for loop statement in a if then statement
any help or clue or any other way for me to to do it ??
Thank you
I am designing a custom ribbon for my application and here is my code Sub FacilityType_Change(control As IRibbonControl, text As String)
Dim Rw As Integer
Dim F As Integer
Worksheets("Report").Activate
Rw = ActiveSheet.Cells(Rows.Count, "d").end(xlUp).Rows
If text = "All Facilities" Then
Cells.Select
Range("E1").Activate
Selection.EntireRow.Hidden = False
If text = "SIS Facilities" Then
Cells.Select
Range("E1").Activate
Selection.EntireRow.Hidden = False
F = 1
For Rw = Rw To 3 Step -1
If Cells(Rw, 3).Value <> F Then
Cells(Rw, 3).EntireRow.Hidden = True
Next Rw
ElseIf text = "Arterial Facilities" Then
Cells.Select
Range("E1").Activate
Selection.EntireRow.Hidden = False
F = 3
For Rw = Rw To 3 Step -1
If Cells(Rw, 3).Value <> F Then
Cells(Rw, 3).EntireRow.Hidden = True
Next Rw
End If
End Sub
when I run it , I get an error Next with out For ,,
Guess I cannot use a for loop statement in a if then statement
any help or clue or any other way for me to to do it ??
Thank you