Excel VBA ActiveX Series #2 Checkbox, Changing cell value on click, and background color!
In this lesson, we explore running a macro or sub when clicking on a checkbox. NOTE: The check box is Boolean, so it's only TRUE or FALSE, checked or unchecked, respectively. This is super cool and very simple to play around with. Check it out!!
**Limited Offer** Learn to Make Excel Do Your Work For You with The Ultimate Excel Programmer Course – Get the Full 9+ Hour Premium Course for 75% off using coupon code: https://www.udemy.com/ultimate-excel-... Click Now to Order and get Lifetime Access to Course, Workbooks, Updates and Support!
------------------------
Create Your Own Barcode Lookup System Using Excel VBA. Learn to Make Your Own Barcode Labels the Easy way and have fun with Barcode Scanners to Automate your Workflow! In this project-driven Course, you’ll learn to Build your own Custom Inventory System with Step-By-Step video instructions. This goes in depth into some advanced Userform strategies that you can use for your other projects to come. A great weekend study! YouTube Subscibers only pay one forth! Get your 75% off Coupon here: https://www.udemy.com/barcodes-excelv...
------------------------
Too busy to Learn Piano? Use my Secrets and Play Your Favorite Songs Today! Did you know; You can learn 4 basic chords in about 5 minutes and instantly be able to play millions of songs. Seriously, check this course out. 75% off for my YouTube Friends! Click here: https://www.udemy.com/play-piano-by-e...
For Articles, Updates and to Contact me for Consulting or just to drop me a line, please visit http://www.ExcelVbaIsFun.com
Here is my link to download my FREE workbooks, past present and future: https://www.dropbox.com/sh/nwc5trm2xw...
------------------------
Playlists:
Excel Vba Basics http://www.youtube.com/watch?v=AIhKNN...
Tips N Tricks https://www.youtube.com/playlist?list...
Userforms https://www.youtube.com/playlist?list...
Sample Excel Programs https://www.youtube.com/playlist?list...
Events Series https://www.youtube.com/playlist?list...
Activex Controls https://www.youtube.com/playlist?list...
------------------------
Grab an Excel Nerd T-Shirt or Hoodie:
http://ExcelVbaIsFun.spreadshirt.com/
------------------------
Interact and Follow me on:
LinkedIn: http://www.linkedin.com/in/danielcstrong
Facebook: https://www.facebook.com/Excelvbaisfun/
Twitter: https://twitter.com/ExcelVbaIsFun
Google Plus+: http://www.google.com/+ExcelVbaIsFun
'Royalty Free Music by http://audiomicro.com/royalty-free-mu...
Closed Caption:
hey there youtubers welcome back this is
daniel strong with another excel vba is
fun lesson today we're going to talk
about the checkbox specifically in the
building Developer tab going to talk
about checkboxes you can put on your
worksheet not in a userform look at the
user forms soon enough i promise you
click on design mode get started we're
going to go to the insert and I'm like
again I like to use active excision
controls more than form controls for a
lot of reasons but let's go ahead and do
the checkbox what is a checkbox let's
put one right about here and we'll just
double click here
oh and did not owe sighs the way I
thought it would
let's see there we go there's a checkbox
again a normal size sheet it would look
well
normal sized zoom in for example
ok so you see the design mode is still
checked so when i'm clicking around here
on our form controls let's see here if I
whatever i right click go to properties
and i'll change the caption right here
to give it a name click here okay
or you could have something else say
what what is this checkbox going to
represent that's that checkbox is always
going to be either true or false
it can have any other value a lot of
times true is one and falses 0 according
to excel so that may help you
let's see here the caption is going to
be what was our objective we're going to
fill this first of all what Phil this
cell here be too with either the word
true or false based on if this is
clicked true if it's unclick true it's a
false right there that's our first task
so we'll just say through false will
have a user click what it is so let's
take design mode off if i click it it
really doesn't do anything right now
let's go back into design mode and we'll
double click on the control
by default actually let's give it a name
let's give it a name
let's click here and we'll call it cb4
checkbox CB t or F or just give it that
name hit enter now it has that name
cbt RS right double-click and now we
have CB trf underscore click so
remembers the name of our form control
so what is our macro going to say we're
going to say we could make this real
easy
let's say range of b2 on the car
worksheet here equals whatever cbt or F
let's see if that works
maybe . value you want to be more
specific than this worksheet . CB trf .
value
alright let's see what happens take
design mode off
click here Oh arranged b2 is taking on
the value of this button click it again
it again
true-false true-false all right now
let's have some more fun
go back and design or double click here
actually I take that bag our second
object if I thought would be cool is to
make the background of this one be
alright let's make be 2 again let's make
the background become red or green based
on what this user clicks and regardless
of what the value is right there so to
do that we need to know what the colors
are let's record a macro doesn't matter
what we call it now let's go here go to
the Home tab will do the color of green
i just want to see what green is and now
we'll cord record the value of red just
for fun and let's see here it's
developer stop recording
I'm gonna hit all the different 11
and you notice it created a module right
here it's usually the most bottommost
module and sure enough here we are so
they said a whole bunch of extra stuff
they're saying anything regarding the
selections interior the dot patterns
this blah blah so what we want to glean
from that is selection . interior .
color equals this and what was that one
that was a green i guess and this 255 is
easy enough that's red put a little
comment to help myself and let's see
let's go ahead and say i'm just going to
copy and paste this whole thing into our
macro so design mode double click here
let's say range of be to the cell
working in . back let's see what is it
what features can we do i think it was i
thought it was a background color
oh no I'm sorry okay i got it
ok it's not the background color i'm
thinking of user forms ok range be too .
remember they said interior . color
equals and I don't remember is going to
give me an error but i'm going to go
ahead and paste some junk down here all
erasing a moment and seeing interior .
color eat dark color equals this was
going to be green 529 blah blah so
there's your green
and we'll copy that and paste it right
here and we know that the other color is
255 which is red okay now let's do an
if-then statement forget this value
we're going to say if the . CB to your f
that value equals true thin and let's
indent this first one if it's true then
green oops
otherwise i say else ok else make it red
and if ok so let's delete all this
ah there's stuff as it's all irrelevant
ok so if the checkboxes value is true
when its run and it's run when you click
it then make the interior color to be
green otherwise so every time the other
time when you click it it's gonna be
ready let's do that take off design
we'll see what happens
true-false true-false true-false anyway
that's pretty much all we're going to do
today and if you wanted you could put
the value on there too
it's kind of like conditional formatting
only you could have a billion conditions
in there
okay so every time the value is true
then the colors green and range be to
that value equals bone anza then when
it's false will have the value to be
equal to
mater milk
awesome let's do this
okay very nice it's working
what is true it's bananas and it's false
it's badger milk
wow there's a lot you can do with that
huh
one more time let's change that to a
number take the quotes out and make it a
number 3477 and ninety-eight cents who
number numbers go to the right text
usually falls on the left
wow that's exciting thanks for tuning
and will go more into depth on
comboboxes internet next
Video Length: 08:49
Uploaded By: ExcelVbaIsFun
View Count: 42,562