K. Georgiadis
10-12-2007, 08:21 AM
Quite a while ago, I got help here with the attached workbook that selects either Automatic Calculation or Manual Calculation by means of two option buttons.
I want to adapt this technique for another application but it has been so long and I find that I no longer remember how the following code for the option buttons actually works:
Private Sub OptionButton1_Click()
' Auto populate
For i = 5 To Range("A65536").End(xlUp).Row
If Left(Range("A" & i), 4) = "Auto" Then
Rows(i & ":" & i).EntireRow.Hidden = False
Rows(i + 1 & ":" & i + 1).EntireRow.Hidden = True
Range("G4") = True
End If
Next
End Sub
Private Sub OptionButton2_Click()
' Manual entry
For i = 5 To Range("A65536").End(xlUp).Row
If Left(Range("A" & i), 4) = "Auto" Then
Rows(i & ":" & i).EntireRow.Hidden = True
Rows(i + 1 & ":" & i + 1).EntireRow.Hidden = False
Range("G4") = False
End If
Next
End Sub
Would you mind terribly deconstructing these two lines for me?
Why "For i =5" ?
If Left(Range("A" & i), 4) = "Auto" Then... Where is it finding "Auto" and why is this line in code the same in both the Auto and Manual option buttons?I really appreciate your help (and your indulgence).
I want to adapt this technique for another application but it has been so long and I find that I no longer remember how the following code for the option buttons actually works:
Private Sub OptionButton1_Click()
' Auto populate
For i = 5 To Range("A65536").End(xlUp).Row
If Left(Range("A" & i), 4) = "Auto" Then
Rows(i & ":" & i).EntireRow.Hidden = False
Rows(i + 1 & ":" & i + 1).EntireRow.Hidden = True
Range("G4") = True
End If
Next
End Sub
Private Sub OptionButton2_Click()
' Manual entry
For i = 5 To Range("A65536").End(xlUp).Row
If Left(Range("A" & i), 4) = "Auto" Then
Rows(i & ":" & i).EntireRow.Hidden = True
Rows(i + 1 & ":" & i + 1).EntireRow.Hidden = False
Range("G4") = False
End If
Next
End Sub
Would you mind terribly deconstructing these two lines for me?
Why "For i =5" ?
If Left(Range("A" & i), 4) = "Auto" Then... Where is it finding "Auto" and why is this line in code the same in both the Auto and Manual option buttons?I really appreciate your help (and your indulgence).