Excel VBA: Hide Pages based on Combobox selection - excel

I have a Combobox with values: "none", "1", "2", "3" and "4". And I want to have visible the number of pages shown by the Combobox. How can I achieve that? i.e. combobox = 3 - Pages 1, 2 and 3 become visible.

An alternative:
Private Sub ComboBox1_Change() ' Could also use a number spinner to control user input
Dim pgCount as Short
' Some data validation
pgCount = IIf(isnumeric(ComboBox1.Text),CShort(ComboBox1.Text),0)
pgcount = iif(pgCount >= 0 and pgCount < 5, pgCount,0)
Me.MultiPage2(0).Visible = pgCount > 0
Me.MultiPage2(1).Visible = pgCount > 1
Me.MultiPage2(2).Visible = pgCount > 2
Me.MultiPage2(3).Visible = pgCount > 3
End Sub
Data validation for user input is always important - how can you handle bad input? A better question is: how can you prevent bad input in the first place.
A little explanation:
The data validation firstly checks if the user has put in something representing a number
If the input resembles a number then convert it to a number. In this case converting it to an Short removes any decimal places the user may have entered.
If the input does not resemble a number, use 0 instead (a soft fail)
If the converted number is between 0 ("None") and 4, then OK, otherwise set it to 0 (another soft fail).
[End of data conversion]
The next four lines use simple Boolean logic to determine if the tab should be shown. I used your answer code to determine the logic.

Finally got it
Private Sub ComboBox1_Change()
Select Case ComboBox1.Text
Case "none"
Me.MultiPage2(0).Visible = False
Me.MultiPage2(1).Visible = False
Me.MultiPage2(2).Visible = False
Me.MultiPage2(3).Visible = False
Case "1"
Me.MultiPage2(0).Visible = True
Me.MultiPage2(1).Visible = False
Me.MultiPage2(2).Visible = False
Me.MultiPage2(3).Visible = False
Case "2"
Me.MultiPage2(0).Visible = True
Me.MultiPage2(1).Visible = True
Me.MultiPage2(2).Visible = False
Me.MultiPage2(3).Visible = False
Case "3"
Me.MultiPage2(0).Visible = True
Me.MultiPage2(1).Visible = True
Me.MultiPage2(2).Visible = True
Me.MultiPage2(3).Visible = False
Case "4"
Me.MultiPage2(0).Visible = True
Me.MultiPage2(1).Visible = True
Me.MultiPage2(2).Visible = True
Me.MultiPage2(3).Visible = True
End Select
End Sub

Related

Add the values to the Option box & Check box

May I know, how to make the option box and checkbox checked as in the list box? Let say, if the data is yes so that the option box will automatically be checked and another one if the choose Whatsapp and email it will automatically be checked at the WhatsApp and email.
The column from Method is starting from column C9 and for Participation at column D9.
FYI,
Emp 2 - Yes Emp 3 - No Emp 8 - Whatsapp Emp 9 - Phone Call Emp 10 -
Facebook Emp 11 -Email Emp 12 - SMS
And here is the coding that I already try
Private Sub lstEmployee_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
'dim the variables
Dim i As Integer
On Error Resume Next
'find the selected list item
i = Me.lstEmployee.ListIndex
'add the values to the text boxes
Dim methodsOfCommunication() As String
Me.Emp1.Value = Me.lstEmployee.Column(0, i)
Select Case Me.lstEmployee.Column(2, i)
Case "Yes"
Emp2.Value = True
Emp3.Value = False
Case "No"
Emp2.Value = False
Emp3.Value = True
End Select
' Reset Methods of Communication checkboxes.
Emp8.Value = False
Emp9.Value = False
Emp10.Value = False
Emp11.Value = False
Emp12.Value = False
' Set Methods of Communication checkboxes.
methodsOfCommunication = Split(Me.lstEmployee.Column(1, i), ", ")
For i = LBound(methodsOfCommunication, 1) To UBound(methodsOfCommunication, 1)
Select Case methodsOfCommunication(i)
Case "Whatsapp"
Emp8.Value = True
Case "Phone Call"
Emp9.Value = True
Case "Facebook"
Emp10.Value = True
Case "Email"
Emp11.Value = True
Case "SMS"
Emp12.Value = True
End Select
Next
Me.Emp4.Value = Me.lstEmployee.Column(3, i)
Me.Emp5.Value = Me.lstEmployee.Column(4, i)
Me.Emp6.Value = Me.lstEmployee.Column(5, i)
Me.Emp7.Value = Me.lstEmployee.Column(6, i)
Me.Emp13.Value = Me.lstEmployee.Column(7, i)
Me.Emp14.Value = Me.lstEmployee.Column(8, i)
Me.Emp15.Value = Me.lstEmployee.Column(9, i)
On Error GoTo 0
End Sub
Dim methodsOfCommunication() As String
Dim i As Integer
Me.Emp1.Value = Me.lstEmployee.Column(0, i)
Select Case Me.lstEmployee.Column(2, i)
Case "Yes"
Me.Emp2.Value = True
Me.Emp3.Value = False
Case "No"
Me.Emp2.Value = False
Me.Emp3.Value = True
End Select
' Reset Methods of Communication checkboxes.
Me.Emp8.Value = False
Me.Emp9.Value = False
Me.Emp10.Value = False
Me.Emp11.Value = False
Me.Emp12.Value = False
' Set Methods of Communication checkboxes.
methodsOfCommunication = Split(Me.lstEmployee.Column(1, i), ", ")
For i = LBound(methodsOfCommunication, 1) To UBound(methodsOfCommunication, 1)
Select Case methodsOfCommunication(i)
Case "Whatsapp"
Me.Emp8.Value = True
Case "Phone Call"
Me.Emp9.Value = True
Case "Facebook"
Me.Emp10.Value = True
Case "Email"
Me.Emp11.Value = True
Case "SMS"
Me.Emp12.Value = True
End Select
Next

How to restart the macro when changing in userform

I do not know how to explain the problem, hope you understand
I use the code to force the user to fill out the form in order
The problem I have is 4 combobox
The 1 opens the 3 or 4 by the value of 1
If I change the value of 1, I have to write the value again in 2 to open the 3 or 4
My problem is that he does not constantly check what the value is in 1, only when there is a change in 2
How can I force the 2 to constantly check the value in 1?
That's the code I have
Private Sub ComboBox2_Change()
Dim lLoc As Long
lLoc = Me.ComboBox2.ListIndex
If lLoc = -1 Then
Me.ComboBox2.SetFocus
ComboBox3.Enabled = False
ComboBox4.Enabled = False
Else
ComboBox3.Enabled = True
End If
If ComboBox1.Text = "abc" Then
ComboBox4.Enabled = True
Else
ComboBox4.Enabled = False
End If
End Sub

How can I fix this code, I keep receiving an infinite loop? [duplicate]

This question already has answers here:
Why MS Excel crashes and closes during Worksheet_Change Sub procedure?
(3 answers)
Closed 4 years ago.
When I run this code and select yes in the cell "bulk" I keep receiving "please enter the number of labor hours" over and over.
Basically what my goal is to have a drop down list to show hidden rows. Then if yes is selected in another drop down list, then two additional box inputs show up
Private Sub worksheet_change(ByVal target As Range)
ActiveSheet.Activate
Rows("20:22").EntireRow.Hidden = True
Rows("23:26").EntireRow.Hidden = True
Rows("27:30").EntireRow.Hidden = True
Rows("51:56").EntireRow.Hidden = True
If Not Application.Intersect(Range("Change"), Range(target.Address)) Is Nothing Then
Select Case target.Value
Case Is = "Asset Transfer": Rows("20:22").EntireRow.Hidden = False
Rows("23:26").EntireRow.Hidden = True
Rows("27:30").EntireRow.Hidden = True
Rows("51:56").EntireRow.Hidden = True
Case Is = "Fund Lineup": Rows("27:30").EntireRow.Hidden = False
Rows("20:22").EntireRow.Hidden = True
Rows("23:26").EntireRow.Hidden = True
Rows("51:56").EntireRow.Hidden = True
Case Is = "Plan Merge": Rows("23:26").EntireRow.Hidden = False
Rows("20:22").EntireRow.Hidden = True
Rows("27:30").EntireRow.Hidden = True
Rows("51:56").EntireRow.Hidden = True
Case Is = "Loans": Rows("51:56").EntireRow.Hidden = False
Rows("27:30").EntireRow.Hidden = True
Rows("20:22").EntireRow.Hidden = True
Rows("23:26").EntireRow.Hidden = True
Rows("28:31").EntireRow.Hidden = True
End Select
End If
Set target = Range("bulk")
If target.Value = "Yes" Then
Dim QtyEntry As Integer
Dim Msg As String
Msg = "Please enter the number of labor hours'"
QtyEntry = InputBox(Msg)
ActiveSheet.Range("c60").Value = QtyEntry
Dim Entry As Integer
Dim Msg1 As String
Msg1 = "Enter percentage increase'"
Entry = InputBox(Msg1)
ActiveSheet.Range("d60").Value = Entry
End If
End Sub
Once your cell has been changed, you can disable events right away, and then re-enable them before exiting the sub.
Also, you start the sub by hiding columns so there is no need to hide them again in your Select Case. All you need to do here is un-hide the rows that you want to be visible.
Also #2, are you sure you don't want your 2nd if statement inside your first if statement? As is, any change will prompt your input boxes.
You can reduce your code to this, which makes your logic a little easier to follow. The main take away is to notice that nothing is done outside of the events being disabled.
Option Explicit
Private Sub worksheet_change(ByVal target As Range)
Application.EnableEvents = False
Union(Rows("20:30"), Rows("51:56")).EntireRow.Hidden = True
If Not Application.Intersect(Range("Change"), Range(target.Address)) Is Nothing Then
Select Case target.Value
Case "Asset Transfer"
Rows("20:22").EntireRow.Hidden = False
Case "Fund Lineup"
Rows("27:30").EntireRow.Hidden = False
Case "Plan Merge"
Rows("23:26").EntireRow.Hidden = False
Case "Loans"
Rows("51:56").EntireRow.Hidden = False
End Select
'Do you want your second IF statement here?
End If
If Range(“bulk”) = "Yes" Then
Range("C60") = InputBox("Please enter the number of labor hours'")
Range("D60") = InputBox("Enter Percentage Increase'")
End If
Application.EnableEvents = True
End Sub
You will likely need to add some validation/error handling for both of your input boxes. What happens if the user puts "one" for number of labor hours? I recommend looking into Application.InputBox so you can control for the input.

How do I have one Userform event procedure (checkbox click) control multiple IF THEN statements?

Hey so I am a beginner with VBA but here is my dilemma:
Creating an excel userform with VBA -
I have a combobox with the numbers 1-8, the number of textboxes shown for the user to fill out is based off of the number selected in the combobox.
I also have a checkbox which, when "TRUE", enables the user to create a custom title for the output of the textbox.
Ex:
Number of Goals = 2
Custom Label Goals? [x] (True)
Goal 1 : $1,000,000
"New Home"
Goal 2 : $50,000
"Boat"
My issue is that I cannot get the number of custom label boxes to be the same as the number of goals selected. So when Number of goals is 2, 8 custom goal textboxes still show up if the checkbox is TRUE.
I found a way using the code below, but when I enter the second IF THEN statement, the first no longer responds to the clicking the checkbox:
Private Sub cbIMPLBL_Click()
If cboIMP.Value = "1" And cbIMPLBL.Value = "True" Then
txtIMPLBL1.Visible = True
txtIMPLBL2.Visible = False
txtIMPLBL3.Visible = False
txtIMPLBL4.Visible = False
txtIMPLBL5.Visible = False
txtIMPLBL6.Visible = False
txtIMPLBL7.Visible = False
txtIMPLBL8.Visible = False
Else
txtIMPLBL1.Visible = False
txtIMPLBL2.Visible = False
txtIMPLBL3.Visible = False
txtIMPLBL4.Visible = False
txtIMPLBL5.Visible = False
txtIMPLBL6.Visible = False
txtIMPLBL7.Visible = False
txtIMPLBL8.Visible = False
End If
If cboIMP.Value = "2" And cbIMPLBL.Value = "True" Then
txtIMPLBL1.Visible = True
txtIMPLBL2.Visible = True
txtIMPLBL3.Visible = False
txtIMPLBL4.Visible = False
txtIMPLBL5.Visible = False
txtIMPLBL6.Visible = False
txtIMPLBL7.Visible = False
txtIMPLBL8.Visible = False
Else
txtIMPLBL1.Visible = False
txtIMPLBL2.Visible = False
txtIMPLBL3.Visible = False
txtIMPLBL4.Visible = False
txtIMPLBL5.Visible = False
txtIMPLBL6.Visible = False
txtIMPLBL7.Visible = False
txtIMPLBL8.Visible = False
End If
End Sub
Any help here would be greatly appreciated.
As I am just beginning is there a different way I am supposed to be doing this, e.g. not writing all of this out individually, but as a control or function (not sure what the term would be) of some sort?
Thank you so much!!!!
Currently both if statements will fire. So if cboIMP.Value = "1" then it first runs through the first if statement and unhides the first text box. But it immediately runs the second if statement and because it does not = "2" it re hides the text box.
There are two choices a select case statement or else if statements.
Select Case:
If cbIMPLBL.Value = "True" Then
Select Case cboIMP.Value
Case 1
'hide/unhide for 1
Case 2
'hide/unhide for 2
Case Else
'Hide all
End Select
End If
Else if
If cbIMPLBL.Value = "True" Then
if cboIMP.Value = 1 then
'do your stuff
Else if cboIMP.Value = 2 then
'do your stuff
Else
'hide everything
end if
End If
This way once the code finds a true it ignores all others. If it does not find any true statements it runs the else.

Why does my BASIC project get an "unexpected <" error?

' Gambas class file
' Math Drill by William Teder. Feel free to use parts of the code, but please give me credit.
' Declare Variables
' Define number of times user has pressed the Give Up button
PRIVATE givenuptimes AS Integer
' Define how many questions the user has answered
PRIVATE questionsanswered AS Integer
' Define what level the user is on
PRIVATE level AS Integer
' Define the number of points the user has
PRIVATE points AS Integer
' Define whether ot not addition, subtraction, multiplication, and division are enabled. This value is changed whrn the textboxes are togglrd.
PRIVATE additionenabled AS Boolean
PRIVATE subtractionenabled AS Boolean
PRIVATE multiplicationenabled AS Boolean
PRIVATE divisionenabled AS Boolean
'Set an integer for counting the number of times the program resets, for use in email.
PRIVATE resetcount AS Integer
' Define variable to help in detrmining the problem type
PRIVATE problemtype AS Integer
' Define number of numbers to add when using an addition problem
PRIVATE currentproblem AS String
PRIVATE currentanswer AS String
PRIVATE currentproblempointvalue AS Integer
PRIVATE add1 AS Integer
PRIVATE add2 AS Integer
PUBLIC SUB Form_Open()
'Set inital values
givenuptimes = 0
questionsanswered = 0
level = 1
points = 0
additionenabled = TRUE
subtractionenabled = TRUE
multiplicationenabled = TRUE
divisionenabled = TRUE
' GET RID OF THE FOLLOWING LINE WHEN USED IN BUILDING OR THE PROGRAM WILL NOT WORK!
' currentanswer = 0
makeproblem()
END
PUBLIC SUB btnClearAnswer_Click()
'clear the contents of txtAnswer and give it the focus
txtAnswer.Text = ""
txtAnswer.SetFocus
END
PUBLIC SUB chkGiveUp_Click()
' Check to see if the Give Up button's visible property is set to true, and if it is, hide the button. If it is hidden, show it again.
IF btnGiveUp.Visible = FALSE THEN
btnGiveUp.visible = TRUE
lblhGiveUp.visible = TRUE
lblGivenUp.visible = TRUE
expSettings.Raise
RETURN
END IF
IF btnClearAnswer.Visible THEN
btnGiveUp.Visible = FALSE
lblGivenUp.Visible = FALSE
lblhGiveUp.Visible = FALSE
expSettings.Raise
RETURN
END IF
END
PUBLIC SUB btnGiveUp_Click()
'Increment the counter that shows the number pf times the user has given up by 1
givenuptimes = givenuptimes + 1
lblGivenUp.Text = givenuptimes
'Display the right answer
txtAnswer.Text = currentanswer
WAIT 2
txtAnswer.Text = ""
points = points - 10
lblPoints.Text = points
makeproblem()
END
PUBLIC SUB chkLevels_Click()
' Check to see if the Level label's visible property is set to true, and if it is, hide the label. If it is hidden, show it again.
IF lblLevel.Visible = FALSE THEN
lblhLevel.Visible = TRUE
lblLevel.visible = TRUE
'Move the answered section down one place, if it is not already
lblhAnswered.Top = 150
lblAnswered.Top = 143
'For some odd reason, when the new objects appear they move themselves forward. Re-lowering the Settings container fixes this.
IF lblGivenUp.Visible = FALSE OR lblAnswered.Visible = TRUE THEN
lblhGiveUp.Top = 200
lblGivenUp.Top = 193
END IF
expSettings.Raise
RETURN
END IF
IF lblLevel.Visible THEN
lblLevel.Visible = FALSE
lblhLevel.Visible = FALSE
'Move the answered section up one place
lblhAnswered.Top = 105
lblAnswered.Top = 98
'Check to see if the GiveUp section needs to be moved
IF lblGivenUp.Visible = TRUE AND lblhLevel.Visible = FALSE THEN
lblhGiveUp.Top = 150
lblGivenUp.Top = 143
END IF
'See above comment
expSettings.Raise
RETURN
END IF
END
PUBLIC SUB btnReset_Click()
' Notify user the program is working
lblProblem.Text = "Resetting, please wait..."
'First, reset variables
givenuptimes = 0
questionsanswered = 0
level = 1
points = 0
'Clear the answer textbox.
txtAnswer.Text = ""
'Next, clear interface.
lblAnswered.Text = "0"
lblLevel.Text = "0"
lblPoints.Text = "0"
lblGivenUp.Text = "0"
' Notify user that the reset has finished and that the program is generating a new problem
lblProblem.Text = "Reset complete, generating new problem..."
makeproblem()
END
' These four subs are the same code with different variables. Changes state of variable the checkbox is assigned to, makes it the opposite of it's current state.
PUBLIC SUB chkAddition_Click()
IF divisionenabled = FALSE AND subtractionenabled = FALSE AND multiplicationenabled = FALSE THEN
PRINT Message("You must select at least one option.")
additionenabled = TRUE
chkAddition.Value = TRUE
RETURN
END IF
' Set the boolean additionenabled to be true or false based on it's current state
IF additionenabled = TRUE THEN
additionenabled = FALSE
RETURN
END IF
IF additionenabled = FALSE THEN
additionenabled = TRUE
RETURN
END IF
END
PUBLIC SUB chkSubtraction_Click()
IF additionenabled = FALSE AND divisionenabled = FALSE AND multiplicationenabled = FALSE THEN
PRINT Message("You must select at least one option.")
subtractionenabled = TRUE
chkSubtraction.Value = TRUE
RETURN
END IF
' Set the boolean subtractionenabled to be true or false based on it's current state
IF subtractionenabled = TRUE THEN
subtractionenabled = FALSE
RETURN
END IF
IF subtractionenabled = FALSE THEN
subtractionenabled = TRUE
RETURN
END IF
END
PUBLIC SUB chkMultiplication_Click()
IF additionenabled = FALSE AND subtractionenabled = FALSE AND divisionenabled = FALSE THEN
PRINT Message("You must select at least one option.")
multiplicationenabled = TRUE
chkMultiplication.Value = TRUE
RETURN
END IF
' Set the boolean multiplicationenabled to be true or false based on it's current state
IF multiplicationenabled = TRUE THEN
multiplicationenabled = FALSE
RETURN
END IF
IF multiplicationenabled = FALSE THEN
multiplicationenabled = TRUE
RETURN
END IF
END
PUBLIC SUB chkDivision_Click()
IF additionenabled = FALSE AND subtractionenabled = FALSE AND multiplicationenabled = FALSE THEN
PRINT Message("You must select at least one option.")
divisionenabled = TRUE
chkDivision.Value = TRUE
RETURN
END IF
' Set the boolean divisionenabled to be true or false based on it's current state
IF divisionenabled = TRUE THEN
divisionenabled = FALSE
RETURN
END IF
IF divisionenabled = FALSE THEN
divisionenabled = TRUE
RETURN
END IF
END
' Subroutine to make a problem
SUB makeproblem()
' This is the code that determines a new problem for the user based on a number of factors, including how many problems of that type they have done,
' whether or not the type is enabled or disabled, how quickly they can answer the question, thier points and level, and how many times they have
' given up on that type of problem. The rest is random. DO NOT MESS WITH THIS CODE UNLESS YOU KNOW WHAT YOU ARE DOING! It is very easy to mess up the program,
' as well as generate stack overflow errors.
' Engine version : 0.0.0.1
' Engine by William Teder
' ------------------------------------
' Generates a random number for the Problem Type, 1 - 4
problemtype = Rnd(1, 5)
IF problemtype = 1 THEN
' Problem Type: Addition
lblProblem.Text = "Problem Type: Addition"
' Determine the number of numbers to add together
IF level <= 5 THEN
' Determine how high the number should be
IF points <= 200 THEN
add1 = Rnd(1, 10)
add2 = Rnd(1, 10)
currentanswer = add1 + add2
currentproblem = add2 & " + " & add1
lblProblem.Text = currentproblem
RETURN
END IF
IF points > 200 AND < 400 THEN
add1 = Rnd(1, 20)
add2 = Rnd(1, 20)
add1 + add2 = currentanswer
currentproblem = add2 & " + " & add1
lblProblem.Text = currentproblem
RETURN
END IF
IF points > 400 AND < 500 THEN
add1 = Rnd(1, 30)
add2 = Rnd(1, 30)
add1 + add2 = currentanswer
currentproblem = add2 & " + " & add1
lblProblem.Text = currentproblem
RETURN
END IF
END IF
IF level <= 10 AND >= 6 THEN
' Code for three numbers
END IF
IF level <= 15 AND >= 11 THEN
'Code for 4 numbers
END IF
IF level <= 20 AND >= 16 THEN
' Code for 5 numbers
END IF
IF problemtype = 2 THEN
' Problem Type: Subtraction
lblProblem.Text = "Problem Type: Subtraction"
END IF
IF problemtype = 3 THEN
' Problem Type: Multiplication
lblProblem.Text = "Problem Type: Multiplication"
END IF
IF problemtype = 4 THEN
' Problem Type: Division
lblProblem.Text = "Problem Type: Division"
END IF
END
PUBLIC SUB gotright()
' Increment questions answered counter
questionsanswered = questionsanswered + 1
' Increment Points
points = points + currentproblempointvalue
' For every 100 points, increment the level counter by 1.
IF level = 1 AND points = 200 THEN level = 2
IF level = 2 AND points = 300 THEN level = 3
IF level = 3 AND points = 400 THEN level = 4
IF level = 4 AND points = 500 THEN level = 5
IF level = 5 AND points = 600 THEN level = 6
IF level = 6 AND points = 700 THEN level = 7
IF level = 7 AND points = 800 THEN level = 8
IF level = 8 AND points = 900 THEN level = 9
IF level = 9 AND points = 1000 THEN level = 10
IF level = 10 AND points = 1100 THEN level = 11
IF level = 11 AND points = 1200 THEN level = 12
IF level = 12 AND points = 1300 THEN level = 13
IF level = 13 AND points = 1400 THEN level = 14
IF level = 14 AND points = 1500 THEN level = 15
IF level = 15 AND points = 1600 THEN level = 16
IF level = 16 AND points = 1700 THEN level = 17
IF level = 17 AND points = 1800 THEN level = 18
IF level = 18 AND points = 1900 THEN level = 19
IF level = 19 AND points = 2000 THEN level = 20
' Change font color of the textbox to green to let the user know he/she got the problem right
txtAnswer.Foreground = &H579524&
' Create delay to let the user know they got the answer right
WAIT 1
' Change back to regular color
txtAnswer.Foreground = &HFF004&
END
PUBLIC SUB txtAnswer_KeyRelease()
IF txtAnswer.Text = currentanswer THEN
txtAnswer.Foreground = &H579524&
questionsanswered = questionsanswered + 1
lblAnswered.Text = questionsanswered
WAIT 0.25
txtAnswer.Text = ""
' Change back to regular color
txtAnswer.Foreground = &HFF0004&
lblPoints.text = points
makeproblem()
END IF
END
PUBLIC SUB Button1_Click()
makeproblem()
END
At line 251, there is an unexpected >. Why does it fail to compile? Thanks.
IF points > 400 AND < 500 THEN
That doesn't look quite right to me, unless your BASIC is really advanced (and it appears GAMBAS isn't quite that advanced). It should be:
IF points > 400 AND points < 500 THEN
You have the right idea with this line, for example:
IF lblGivenUp.Visible = TRUE AND lblhLevel.Visible = FALSE THEN
Same for all the variations you have of this, you need to include the variable on the right hand side of the and as well):
IF points > 200 AND < 400 THEN
IF points > 400 AND < 500 THEN
IF level <= 10 AND >= 6 THEN
IF level <= 15 AND >= 11 THEN
IF level <= 20 AND >= 16 THEN

Resources