1

This code is intended to place the word "New" if the checkbox is checked, and a ✓ checkmark if it's unchecked.

If CheckBox2.Value = False Then
Cells(3, 3) = ChrW(&H2713)  # <-- checkmark ✓
Else: Cells(3, 3) = "New"
End If

However, currently, this only places the word "New" if the checkbox is selected, but it won't place a ✓ checkmark if it's not selected! I can get a checkmark to be displayed when they select the checkbox then unselect the checkbox, but this is cumbersome.

How do I fix this?

Vityata
  • 42,633
  • 8
  • 55
  • 100
CptGoodar
  • 303
  • 2
  • 15
  • Sounds like you're firing this code in the change event of the checkbox itself so it won't fire until you select or deselect it. You may need to duplicate this piece of code into another step if you want it to fire regardless if they change the checkbox or not. – Dave Dec 18 '17 at 11:54
  • So you want to show ✓ by default? – Jean-François Corbett Dec 18 '17 at 12:01
  • @Jean-FrançoisCorbett i do, but i have found a solution now to the problem . thank you for your help though – CptGoodar Dec 18 '17 at 12:04

1 Answers1

2

This is probably the easiest & dirtiest solution:

Private Sub CheckBox1_Click()        
    If CheckBox1.Value Then
        Cells(3, 3) = "New"
    Else
        Cells(3, 3) = ChrW(&H2713)
    End If        
End Sub

Every time you select the checkbox, the C3 cell would be updated with either or New. There is a better way to do this, but it requires Object Oriented Programming - Is VBA an OOP language, and does it support polymorphism?

References for the "better way":

Vityata
  • 42,633
  • 8
  • 55
  • 100
  • 1
    Found a bodge way of doing it, used the exit button on the UserForm as the code runner. Each checkbox has no code associated with it, just a value. So when you exit the UserForm it assigns the cell is vlaue based off the checkbox's value that way – CptGoodar Dec 18 '17 at 12:03
  • @CptGoodar - this sounds like a really robust option as well. Just make sure that you do some good error catching there. – Vityata Dec 18 '17 at 12:04
  • Thank you, hopefully will work well. Haha yeah i need to with 87 options that could be changed :P – CptGoodar Dec 18 '17 at 12:19
  • @CptGoodar - for 87 options, I would invest a bit time in learning OOP and do it from there. Otherwise it would be a difficult task for maintenance (but a wonderful job defence!) :) – Vityata Dec 18 '17 at 12:47
  • @Viyata, is VBA able to cope with OOP? Needs to be through VBA for the ease of use with the guys downstairs – CptGoodar Dec 18 '17 at 13:31
  • 1
    @CptGoodar - https://stackoverflow.com/questions/31858094/is-vba-an-oop-language-and-does-it-support-polymorphism – Vityata Dec 18 '17 at 13:33