Dates in textboxes?

dan2

Board Regular
Joined
Mar 26, 2002
Messages
60
I have formated a text box to display dates with the following line in the textbox code:

Private Sub TextBox1_Change()
TextBox1.Text = Format(Range("$bi$4"), "dd-mmm-yy")
End Sub

It works fine until I print preview or print the page and then it goes back to date code and isnt formatted anymore.

Anyone know how I can avoid this happening?

TIA

Dan.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi Dave

No the textbox is on a spreadsheet.

I could make it so the date appears in the cell below the textbox and then make the textbox not print but I wondered if there was a way not to cheat for a change.

Dan.
 
Upvote 0
Dan, I am unable to generate this problem with Excel 2000, the date prints just as show. Anyway try this.

Private Sub TextBox1_Change()
Dim strDate As String
strDate = Range("A1")
TextBox1 = Format(strDate, "dd/mmm/yy")
End Sub
 
Upvote 0
Dave

Im using XP so I dont know if its a bug in the new version.

Your new code still does the same.

Grrrr looks like Ill have to cheat (as per usual)

Thanks

Dan.
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,186
Members
448,554
Latest member
Gleisner2

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