#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default Textbox to show date

Hi all,

HYCH with this

Am using the form below, but did not want the date entered into
textbox2, would prefer that the current date is displayed and have the
textbox disabled..

I know how to accomplish the disabled bit, but am a little stuck with
regards the date issue,
tried to format "=today()" but to no avail,

Would it require a 'userform initiate sub' command to accomplish
this ?

code attached


Private Sub CmdAdd_Click()
Dim ws As Worksheet
Set ws = Worksheets("All Deals")

ws.Cells(2500, 1).Value = Me.TextBox1.Value
ws.Cells(2500, 2).Value = Format(Me.TextBox2.Value, "today()")
ws.Cells(2500, 3).Value = Me.TextBox3.Value

Me.TextBox1.Value = ""
Me.TextBox3.Value = ""
Me.TextBox2.Value = ""
Me.TextBox1.SetFocus


Unload Me

End Sub

Private Sub CmdClose_Click()
Unload Me
End Sub




Steve

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Textbox to show date

In VBA:

Sub routine()
Range("A1").Value = Date
End Sub

--
Gary''s Student - gsnu2007


"K1KKKA" wrote:

Hi all,

HYCH with this

Am using the form below, but did not want the date entered into
textbox2, would prefer that the current date is displayed and have the
textbox disabled..

I know how to accomplish the disabled bit, but am a little stuck with
regards the date issue,
tried to format "=today()" but to no avail,

Would it require a 'userform initiate sub' command to accomplish
this ?

code attached


Private Sub CmdAdd_Click()
Dim ws As Worksheet
Set ws = Worksheets("All Deals")

ws.Cells(2500, 1).Value = Me.TextBox1.Value
ws.Cells(2500, 2).Value = Format(Me.TextBox2.Value, "today()")
ws.Cells(2500, 3).Value = Me.TextBox3.Value

Me.TextBox1.Value = ""
Me.TextBox3.Value = ""
Me.TextBox2.Value = ""
Me.TextBox1.SetFocus


Unload Me

End Sub

Private Sub CmdClose_Click()
Unload Me
End Sub




Steve


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Textbox to show date

with ws.Cells(2500, 2)
.numberformat = "mm/dd/yyyy"
.Value = date
end with

If you really want the cell to hold a formula (that will change every day):

with ws.Cells(2500, 2)
.numberformat = "mm/dd/yyyy"
.formula = "=today()"
end with



K1KKKA wrote:

Hi all,

HYCH with this

Am using the form below, but did not want the date entered into
textbox2, would prefer that the current date is displayed and have the
textbox disabled..

I know how to accomplish the disabled bit, but am a little stuck with
regards the date issue,
tried to format "=today()" but to no avail,

Would it require a 'userform initiate sub' command to accomplish
this ?

code attached

Private Sub CmdAdd_Click()
Dim ws As Worksheet
Set ws = Worksheets("All Deals")

ws.Cells(2500, 1).Value = Me.TextBox1.Value
ws.Cells(2500, 2).Value = Format(Me.TextBox2.Value, "today()")
ws.Cells(2500, 3).Value = Me.TextBox3.Value

Me.TextBox1.Value = ""
Me.TextBox3.Value = ""
Me.TextBox2.Value = ""
Me.TextBox1.SetFocus

Unload Me

End Sub

Private Sub CmdClose_Click()
Unload Me
End Sub

Steve


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need A date Mask format for a Textbox on UserForm [email protected] Excel Discussion (Misc queries) 2 November 4th 07 02:27 AM
Textbox date format. AOU Excel Discussion (Misc queries) 2 April 24th 07 02:28 PM
Date format textbox George Excel Discussion (Misc queries) 2 September 20th 06 09:09 PM
select from combobox and show a price in textbox gem New Users to Excel 1 June 14th 06 11:37 AM
multiply two numbers and show the answer in a textbox gem Excel Discussion (Misc queries) 5 June 14th 06 12:07 AM


All times are GMT +1. The time now is 03:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"