VBA, Excel Date Problem

S

shilparvind

Hi,

I am using VBA's inbuilt date function. I am making that date to print
in one of Excel sheet's cells. The problem is date is printed on the
cell as #########. When i click on that cell i can see the correct date
in the formula bar. What is wrong? Below is my code:

Private Sub txtDate_Change()
txtDate = Format(Date, "mm/dd/yy")
Cells(1, 2) = txtDate.Text ' Printing it in the B1 cell
End Sub

I even tried something like this:

Sub Macro1()
Range("B1").NumberFormat = "dddd mmm.d yyyy"
Range("B1").Value = Date
End Sub

In both the cases the answer is ####### in the B1 cell.

Any help on this will be greatly appreciated. I dont know where i am
going wrong.

Regards
Shilpa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top