ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run VBA on Checkbox Value (https://www.excelbanter.com/excel-programming/343724-run-vba-checkbox-value.html)

stacy[_2_]

Run VBA on Checkbox Value
 
Hello... I have what is probably a simple problem, but can't figure out
a solution. I have a worsheet that contains cells for Contact
information (e.g. Name, Phone Number, etc.). In addition, there is
another, identical group of cells asking for the same Contact
information... THis information will either be identical to what we
provided by the user before, or something completely different.

What I would like to do is to simplify the process when the information
will be identical by adding a Checkbox next to the second section
stating basically "If the following information the same as above,
please check here...". When the check the Checkbox, I will pull the
information from Cells (let's say) A1, A2 ans A3, and place in B1, B2
and B3.

The problem I am running into is that I can get the information to
populate just fine. However, if they were to change their mind, and
UNcheck the Checkbox, I would like to undo the process, basically
erasing the information.

Any ideas would be greatly appreciated. And as always, thanks in
advance!!!


baj

Run VBA on Checkbox Value
 
Hi,

If you fill in a checkbox this means basically that you put the value
on TRUE, if you unfill it you put it on FALSE so you can connect a
little procedure with it. With a simple If...Then Structure you can Do
an action (fill certain cells) or UnDo (erase) the action :

Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
TextBox1 = "one" ' I used a textbox in a userform that get s filled
with the word "one" if the Checkbox1 is clicked on
Else ' and this textbox is erased when it s been
unchecked again
TextBox1 = "" ' ofcourse you can replace these steps by the
steps filling/erasing cells in a worksheet
End If
End Sub


Bye
Baj


baj

Run VBA on Checkbox Value
 
Hi,

Sorry the programcode got a bit messed up with the commentary so I try
again :

If you fill in a checkbox this means basically that you put the value
on TRUE, if you unfill it you put it on FALSE so you can connect a
little procedure with it. With a simple If...Then Structure you can Do
an action (fill certain cells) or UnDo (erase) the action :


Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
TextBox1 = "one"
Else
TextBox1 = ""
End If
End Sub

I used a textbox in a userform that get s filled with the word "one" if
the Checkbox1 is clicked on
and this textbox is erased when it s been unchecked again
ofcourse you can replace these steps by the
steps filling/erasing cells in a worksheet

Bye
Baj


stacy[_2_]

Run VBA on Checkbox Value
 
Okay, that makes sense, but I may have another issue.

What I have is, let's say, the following:

Cell M15 will be filled out with "Name"
Cell M16 will be filled out with a "Phone Number"

I have a checkbox (Which is actually Checkbox25)

If they Click this Checkbox25, I want the information from M15 and M16
to populate M24 and M25. If they Uncheck the Checkbox25, I would like
for the information in M24 and M25 to disappear... Still leaving M15
and M16 unchanged.

I am having issues with writing this part of the code... Any help?



All times are GMT +1. The time now is 01:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com