Populate checkbox based on cell value

p9j123

Active Member
Joined
Apr 15, 2014
Messages
288
Office Version
  1. 2013
Platform
  1. Windows
I have a vba macro that will populate values of checkbox to a cell, the macro saves in C1 anything that were checked... so if the City has check box, C1 will become City, if there are multiple check box selected let say, City, Province and Town, C1 will become City, Province, Town. This works perfectly fine.

[ ] City
[ ] Province
[ ] Town
[ ] District

Now, I have to creat a edit form, where when I clicked edit all of the content in rows will be populated on the designated text box.

I need help on doing the same for check box.

So if C1 has City, then City Checkbox should be cheked, if C1 has City, Province and Town then the corresponding 3 checkbox should be checked as well.
 

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)
Try this

VBA Code:
Private Sub EditForm_Click()
  If InStr(1, Range("C1"), "City", vbTextCompare) > 0 Then CheckBox1.Value = True
  If InStr(1, Range("C1"), "Municipal", vbTextCompare) > 0 Then CheckBox2.Value = True
  If InStr(1, Range("C1"), "Province", vbTextCompare) > 0 Then CheckBox3.Value = True
  If InStr(1, Range("C1"), "District", vbTextCompare) > 0 Then CheckBox4.Value = True
End Sub
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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