VBA "CheckBox1.Value = True" Not working..

BenGee

Board Regular
Joined
Mar 5, 2016
Messages
196
I have a command button and amongst the code is this;
Code:
If Range("AM4").Value = "ASH" Then
        CheckBox1.Value = True
End If

However, when run the command button, I get an error on the above code and cannot work out where I'm going wrong! Any help would be appreciated.

Thank you
 
Last edited:

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
The only way I see that not working is if checkbox1 object does not exist in that userform.
 
Upvote 0
That's what I thought..

Maybe it's something else, the whole code is
Code:
Sub Button69_Click()
    Range("AM4").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B4,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM5").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B5,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM6").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B6,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM10").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B10,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM11").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B11,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM12").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B12,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM13").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B13,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM14").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B14,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM15").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B15,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM16").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B16,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM17").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B17,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM18").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B18,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM22").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B22,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM23").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B23,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM24").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B24,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM25").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B25,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM26").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B26,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM27").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B27,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM31").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B31,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM32").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B32,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM33").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B33,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM34").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B34,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM35").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B35,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM36").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B36,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM37").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B37,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM38").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B38,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM39").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B39,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    Range("AM40").FormulaArray = "=INDEX(Shifts!$B$5:$AE$35,MATCH('Day Plan'!B40,Shifts!$A$5:$A$35,0),MATCH(TODAY(),Shifts!$B$2:$AE$2,0))"
    If Range("AM4").Value = "E" Then
            Range("P4:S4").Value = "Lunch"
            Range("T4:W4").Value = ""
        End If
        If Range("AM4").Value = "MS" Then
            Range("R4:U4").Value = "Lunch"
            Range("P4:Q4,V4:W4") = ""
        End If
        If Range("AM4").Value = "L" Then
            Range("T4:W4") = "Lunch"
            Range("P4:S4") = ""
        End If
        If Range("AM4").Value = "ASH" Then
            CheckBox1.Value = True
    End If
    If Range("AM5").Value = "E" Then
            Range("P5:S5").Value = "Lunch"
            Range("T5:W5").Value = ""
        End If
        If Range("AM5").Value = "MS" Then
            Range("R5:U5").Value = "Lunch"
            Range("P5:Q5,V5:W5") = ""
        End If
        If Range("AM5").Value = "L" Then
            Range("T5:W5") = "Lunch"
            Range("P5:S5") = ""
        End If
        If Range("AM5").Value = "ASH" Then
            CheckBox42.Value = True
    End If
End Sub

Also separate to this command button, CheckBox1 if True, is putting "ASH" between "D4:AK4,AM4".. Would this cause some kind of conflict? Perhaps this is it?
 
Upvote 0

Forum statistics

Threads
1,223,445
Messages
6,172,176
Members
452,446
Latest member
walkman99

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top