i'm going to show you how to write a
simple little macro that will check to
see if fields have been completed on
your sheets i have a very simple example
here I have a sheet that's asking for
your first name and your last name so
let's go to the Developer tab let's go
to visual basic and then we will go
insert and we'll go new module
I will drag this over you so you can see it and
so i'm i'm going to call my sub got info
so go sub got info
ok and I'm going to put that and end sub
is what my my little thing means here so
let's go to start here and i'll say so
the fields that we're looking at if I
pull this aside so it's c4 is for the
first name so what I'm going to do is
I'm going to go if and where you can use
the command is empty and then i'm going
to go range and then i'm going to do
another bracket and i'm going to put
quotation marks and you go see four and
then put in quotation marks and brackets
and maybe another bracket to end this
for the range then go if that's a empty
then and we're going to create a message
boxs
and it's going to say enter first name
and then I'm going to put a little
failsafe in it so I'm going to go go to
and end s to go to my my bottom here so
so if that one's fine let's go to the
next one so we'll go else and we'll go
same thing if is empty and we'll go
range and a little another bracket and
i'll go case marks e4 and any quotation
marks and the bracket into practice and
i'm going to go then and if that affects
empty then we're going to generate
another message box
we're gonna go msgbox x and I
going to say enter last
extra quotiation
okay we're good now I'm same thing is
well here to go to okay so the big the
big thing about IFs is that you have to
count your if we got 2 and so we're
gonna have to have 2 end ifs will go
and if and then we're going to do
another and if so just because I don't
always trust myself what I'm going to do
is I'm going to go on I'm gonna go to
the debug on the ribbon here and i'm
going to debug and I'm gonna go compiled
vba project and it doesn't appear that
there is anything wrong with it so now
i'm just going to go off to the side
here and so I'm going to run this
program and so we can see your sheet a
little bit back here so there's nothing
in either one of them so what let's
let's see what happens
so and then the message box enter first
name so i can say okay and so the
program goes the end because we don't
have a first name in there so now let's
put in Barney ok and so let's run our
program again so let's run it and see it
it would pass the barney and now it's
going to last time saying that you got
into the last name here so i'll say ok
and I'm going to put in rubble and then
let's run our program one more time
and there is no error message come out
so it's working perfectly
so that's a simple little macro just to
test if it feels have been completed
please subscribe