If checkbox ticked then skip if statements and run macro

A

amorrison2006

Hi

I have a macro that loops through multiple files in excel and for each
file asks the user two questions using msg box.

if the user clicks yes it runs one macro and if the user clicks no
then it runs another.....

These are done using if statements.

What I would prefer to do is to add a checkbox on the sheet itself and
if it is checked it will carry out the same process for all the sheets
it loops through rather than ask the user to do the same thing.

Some users will want to answer the questions as they may want to do
the same thing for one of the sheets and not for others. Other users
will want to do the same thing for all of them. The macro should
first check if the sheet is ticked and if not then ask the questions
for each of them. If the box is ticked then do the same thing for all
the sheets.

Is this possible?

Someone please help me with a script as I have been trying this for a
long time now and it is really getting on my nerves.

Thanks so much,

Andrea
 
M

Mole Hunter

Andrea,

To use a check box is fairly straightforward. Add the checkbox
control to the sheet. Then at the start of your macro you can use an
if statement to test whether or not it is checked.

If checkbox1.value = true then 'This TRUE means that it is checked.
A FALSE value would mean unchecked.
some code here
else
some other code here
end if


I hope that I have understood your question correctly.

-- J
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top