Auto fill?

cbm550

New Member
Joined
Feb 13, 2006
Messages
30
I need to be able to click on a box and have it fil that box with a check, X, or other fill and have that fill go away if I click on that box again. Can I do that?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I need to be able to click on a box and have it fil that box with a check, X, or other fill and have that fill go away if I click on that box again. Can I do that?
I assume a "box" is actually a "cell"??

I would suggest using a double click. The code below places an "x" in the cell if the cell was previously empty, it empties the cell if it previously contained an "x" and it leaves the cell as is if it contains anything else.

Right click the sheet name tab and choose "View Code".
Paste this in the right hand pane that opens in the VB window.
Close the VB window and try some double clicks.

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_BeforeDoubleClick(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range, Cancel <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Boolean</SPAN>)<br>    <SPAN style="color:#00007F">If</SPAN> Target.Value = "" <SPAN style="color:#00007F">Then</SPAN><br>        Target.Value = "x"<br>    <SPAN style="color:#00007F">ElseIf</SPAN> Target.Value = "x" <SPAN style="color:#00007F">Then</SPAN><br>        Target.ClearContents<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
When I double click on a box, it comes back with "Run-time error 13: Type mismatch." And when I click on debug, it highlights the second line, "If Target.Value = "" Then"
 
Upvote 0
When I double click on a box, it comes back with "Run-time error 13: Type mismatch." And when I click on debug, it highlights the second line, "If Target.Value = "" Then"
You haven't confirmed whether yout "box" is actually a "cell" or something else.

Do you get the error no matter where you double click?

Tell us a bit more about what you have on your sheet and what you are trying to do.

What version of Excel are you using?

How do I assign which cells I want to use this formula on?
The best method may depend on the answers above. Which cells do you want it to work on?
 
Upvote 0
I am sorry for the confusion. I have converted a form that we used to fill out and put it on an excell sheet. The boxes that I need to check and uncheck are actually a box that is formed from merged cells. there are other boxes that I have merged to put in information as well. So I need to be able to click once to check a box and click once to uncheck it if it was checked in error and be able to input data (words or numbers) in the other merged boxes. The whole sheet is protected except for the input boxes.

I hope this clarifies my issue. Thanks for your help.
 
Upvote 0
I am sorry for the confusion. I have converted a form that we used to fill out and put it on an excell sheet. The boxes that I need to check and uncheck are actually a box that is formed from merged cells. there are other boxes that I have merged to put in information as well. So I need to be able to click once to check a box and click once to uncheck it if it was checked in error and be able to input data (words or numbers) in the other merged boxes. The whole sheet is protected except for the input boxes.

I hope this clarifies my issue. Thanks for your help.
So you want to be able to click on some merged cells and have an "x" added or removed from the merged cells. Other merged cells you want to be able to click on and not add/remove "x" but be able to add data. Is that correct?

If so, then you need to answer my previous question:
Which cells do you want it to work on?
 
Upvote 0
You are correct. Now, I am assuming that I need to give you the exact cells that I have that need the check mark? If so, I have 4 sheets that I have between 50 and 70 check boxes each.
 
Upvote 0

Forum statistics

Threads
1,214,780
Messages
6,121,527
Members
449,037
Latest member
tmmotairi

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