VBA code to make check boxes appear based on first character of a cell

Because Reasons

New Member
Joined
Nov 27, 2016
Messages
6
Hey everyone, long time lurker, first time poster. I can usually find any answers I need just by searching but I'm having some difficulties with finding a suitable answer for this one.


I've got an invoice that I'm building and adding checkboxes for various up-charges, 50% and 200% to be precise, for each line. These checkboxes are only going to appear for certain categories of items the merchant sells, and all "Item Number"s start with a number denoting the category it falls into.

I've figured out the easy part of how to make the checkbox appear based on specific values of a cell, but I'm having difficulty finding help to determine if the first digit of the "Item Number" is specifically a 2, 3, or 4.

This is what I'm starting with:

If wss.Range("A18") = "3PRNT.DFx50%***" Then
wss.CheckBox2.Visible = True
Else
wss.CheckBox2.Visible = False
End If

The underlined is the part that I'm needing help with since this is where I started just to test the functionality of the code. I've looked at the link below which gives me the idea that I can check whether the value is a number or letter, but I need to find specific numbers.

http://www.mrexcel.com/forum/excel-...tion-check-if-3rd-character-cell-numeric.html

Any insight you may be able to provide, or even links to good resources would be much appreciated.

Thanks!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
WELCOME TO THE FORUM :)

Would you be looking for something like
Code:
If Left(wss.Range("A18").value,1)="3", then
 
Last edited:
Upvote 0
Yes! That works exactly as I was hoping. The following is what I ended up with for the multiple categories:

If Left(wss.Range("A18").value,1)="3" or Left(wss.Range("A18").value,1)="2" or Left(wss.Range("A18").value,1)="1" then
wss.CheckBox2.Visible = True
Else
wss.CheckBox2.Visible = False
End If

Thanks for the assistance!
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,409
Members
448,959
Latest member
camelliaCase

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