How to insert a checkmark with vba

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
563
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I have a pass or fail option buttons. if the user selects "pass" option button a green check mark appears on the designated cell on the spreadsheet. The problem is I can't find a check mark in ascii only in Unicode. So I guess my question is how can I display a check mark and turn it green using colorindex?
Thanks
 
oh ya, forgot to ask. Since this only works for certain fonts. Is there a way to set the font for this cell to one of the designated fonts? thanks again.
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I'm glad it's working.

I don't think that in a present system you have to worry about the font supporting Unicode, but you can force a font style if you want.

Check the help on the Font object to learn how to change the font properties.

for ex., for the colour:

Code:
Cells(emptyrow, 7).Font.Color = vbGreen
 
Upvote 0
Thank You very much for your help however if this is what you meant:
If OptionButton1 = True Then
Cells(emptyRow, 7).Value = ChrW(&H2713)
Cells(emptyRow, 7).Font.Color = vbGreen
Else
Cells(emptyRow, 7).Value = "X"
End If

It returned a runtime error '1004'
 
Upvote 0
What's the value of emptyRow when you get the error?
 
Upvote 0
Everything worked great until I added

Cells(emptyRow, 7).Font.Color = vbGreen

part of the code. If I remove this code it goes back to running normal. But would like this character to be the colour green, if possible.
 
Upvote 0
It also seems to me that emptyRow has an invalid value.

Please try your code with a fixed value for emptyRow, like:

Code:
If OptionButton1 = True Then
    Cells(1, 7).Value = ChrW(&H2713)
    Cells(1, 7).Font.Color = vbGreen
Else
    Cells(1, 7).Value = "X"
End If

and see if you get an error.
 
Upvote 0
I appreciate everyone's help. Unfortunately, I can't assign a specific row. Everytime a user opens this form and enters all the values and clicks "ok" it drops down the previous inputed values to the next row and so on.
 
Upvote 0
I did not mean you should assign a specific row.

The test I posted with emptyRow replaced by 1 is just to show you that the code is ok, it's the value of emptyRow that is invalid.

So, please test the code with the 1 and see if it produces an error. If it executes ok and cell G1 gets a green checkmark, then you know that the error in the the value of the variable emptyRow and not in the code syntax.
 
Upvote 0
I'm sorry, I cannot reproduce your error.

Maybe if you post the whole code, including the declaration and initialisation of the variables and objects it will be possible to understand, but not for me today.

I'll check this thread tomorrow.

I hope you or someone else find the error. If you find the error please post back.
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,840
Members
449,193
Latest member
MikeVol

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