View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ben McClave Ben McClave is offline
external usenet poster
 
Posts: 173
Default Formatting automatically filled cells

Hello,

It sounds to me like the userform is returning a string rather than a date. If you Dim a Date field for your userform, it may help. The code would read something like this:

Private Sub CommandButton1_Click()
Dim dDate As Date
dDate = TextBox1.Value
Sheet1.Range("A50000").End(xlUp).Offset(1, 0).Value = dDate
End Sub

Alternatively, you could look at using a function like "CDate" in VBA to coerce the number into a date format. Or maybe using the "DateValue" and "IsText" functions in Excel to convert the string version of the date to a numeric value. For example, Cell AC1 might be changed to:

=IF(ISTEXT(INDEX(A:A,MATCH(AB1,B:B,0))), DATEVALUE(INDEX(A:A,MATCH(AB1,B:B,0))), INDEX(A:A,MATCH(AB1,B:B,0)))

Good Luck,

Ben