• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code for warning "box has already been clicked"???

Hello,

I have found various solutions on the net, but none of them seem to address my specific need. Maybe I am just not using the correct search terminology...

I know it is going to take VBA code, but I am just not knowledgeable enough in VBA to figure it out. What I need is to assign a macro to the checkboxes in my program:

In my program a teacher checks a box when a student has handed in his/her assignment. If a teacher checks an assignment box the date is time stamped, so I do not want him /her to be able to accidentally uncheck the box at a later time and then click it again as it then changes the static timestamp for the assignment.

so basically something like this:

1) Is it checked...if so..message confirmation box "do you want to uncheck this box?" yes...uncheck. No keep it checked.
2) Is it unchecked, let the user click it with no warning.


I doubt there is a way to apply this to all checkboxes on the sheet simultaneously, but I am willing to go through the tedium of applying it to all checkboxes.

Thanks for your time
 
Last edited:
Hi ,

When your problem involves either Form or ActiveX controls , please upload a sample workbook with the same controls ; otherwise you are compelling those who would like to help , to recreate those controls and then write the code.

If members are expert enough to write the code without having to create the controls , the resulting code may or may not work , since if it requires tailoring for your setup , you say you are not knowledgeable in VBA.

Please upload a sample workbook for faster resolution of problems involving VBA code for Form / ActiveX controls.

Narayan
 
Thanks for your response. Here is the checkbox template that I am working with.
 

Attachments

  • checkbox layout.xlsx
    276.6 KB · Views: 5
Hi ,

Going by what you have posted , can I assume that the automatic time-stamping is being done by you ?

If so , then what is required is only to test whether the checkbox is being unchecked ; if the checkbox is being checked , no test is required. Is this correct ?

If so , see this file. Copy the code and paste it in your file , since I have broken the links of the checkboxes.

Narayan
 

Attachments

  • checkbox layout.xlsm
    247.4 KB · Views: 8
Awesome! Exactly what I was looking for. You seem to have it attached to all of the check boxes. There must be a way to do this without going to each and every checkbox then, but I do not know what that is.
 
Hi ,

That is being done by the Application.Caller property , which gives the name of the object that was clicked ; thus , by just using this one property , we get the name of the checkbox that was checked /unchecked , which makes it possible for just one macro to work for all 200+ checkboxes !

Narayan
 
I am a bit confused. Where do I paste the code? Is there some part that is the Application.Caller property? I attached it to a single box and it works just like I want. I am just confused as to how/where to insert it so it works for all boxes.

Thanks again. Figuring this out moves my concept way ahead in terms of practical use.
 
Hi ,

You don't have to do anything much ; press F5 or do CTRL G to bring up the Go To dialog ; select Special , Objects ; all of the checkboxes should be selected.

Right click and select Assign Macro , and assign the same macro to all the checkboxes. That's all.

Narayan
 
Back
Top