I created a series of questions. Depending on the answer, VBA code will unhide/hide rows if additional information is required.
For instance, for the question is "Do you own a home?"
- If the user selects Yes, the code will unhide the next row and will require them to fill out their address.
- If the user selects No, the code will keep the the Address row hidden because it is not necessary that the user fill anything out.
The next step I want to implement is to focus the cursor on the next row to help the user in navigating the form. So in the previous example, if the user selects Yes, I'd like to implement VBA code that will put the cursor on the next row using code similar to this:
If UCase(Range("I2").Value) = "NO" Or IsEmpty(Range("I2").Value) Then
Rows("3:3").EntireRow.Hidden = True
Else: Rows("3:3").EntireRow.Hidden = False
Range("I3").Select
End If
If UCase(Range("I6").Value) = "NO" Or IsEmpty(Range("I6").Value) Then
Rows("7:7").EntireRow.Hidden = True
Else: Rows("7:7").EntireRow.Hidden = False
Range("I7").Select
End If
There is about 100 questions, and though this method works for one question/answer, the code gets messed up because on later questions (like in the example above), the VBA code keeps on selecting cell I3 because cell I2 remains as "Yes".
Rather than using the .Select method, is there another way so the VBA code will move the cursor to the next appropriate cell despite previous entries?