TextBox to display date or "NA"

AndyEd

Board Regular
Joined
May 13, 2020
Messages
124
Office Version
  1. 365
Platform
  1. Windows
I have a number of TextBoxes that either display a Date, remain blank, or display "NA" if a date is not required.

They are three distinct options - 1) Date required and present; 2) Date required and missing (Blank); 3) Date not required ("NA")

I've formatted the TextBox to highlight it if it is blank (requires an entry).

The issue I have is that I'm using Format(CDate(TextBox),"dd/mm/yy") to display the date and of course it is finding a error as soon as it encounters an "NA". If I don't format the code to display a date, it is displaying the numerical code instead. I've tried various "if" functions in the "Change" sub for the TextBox, but nothing seems to have the desired effect.

I'm not sure where I'm going wrong.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I'm not sure how to attach a workbook to this thread?
 
Upvote 0
I'm not sure how to attach a workbook to this thread?
You can't, but you can upload a sample workbook (without sensitive data) to a sharing site like dropbox.com or google drive.
And then share the link here.
 
Upvote 0
The issue was the use of CDATE. When using Format it works fine....Doh!
 
Upvote 0
Solution
Hey, thanks for taking the time to help though. Appreciated.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,958
Members
449,096
Latest member
Anshu121

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