Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default User Forms and Date Formats

Hi there,

I have two problems with some user forms i am trying to create.

Firstly the following code takes the entries from the data form into a
worksheet
ws.Cells(iRow, 2).Value = Me.txtstdt.Value
ws.Cells(iRow, 3).Value = Me.txtendt.Value

both txtstdt and txtendt are dates which are to be dd/mm/yy, however appear
on my worksheet as mm/dd/yy. Can anyone help me format them correctly? The
code appears to overwrite the cell formatting.

Secondly I have a job number layed out as 12-3456 which is entered into a
form and this code puts it into another worksheet

ws.Cells(iRow, 1).Value = Me.txtjobno.Value

My problem here is that it formats it as a date even though my worksheet
formattin is and should be set to general.

Any ideas very welcome!

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default User Forms and Date Formats

with ws.Cells(iRow, 2)
'just an unambiguous date for testing, change it when you're happy it's ok
.numberformat = "mmmm dd, yyyy"

'cdate() uses the windows setting (mdy order) for the user
'and that may not be what you (the developer) expects!
.Value = cdate(Me.txtstdt.Value)
end with

And I'd just format that other cell as text first.

with ws.Cells(iRow, 1)
.numberformat = "@"
.Value = Me.txtjobno.Value
end with

or start the entry with an apostrophe:
ws.Cells(iRow, 1).Value = "'" & Me.txtjobno.Value
so that it would be entered as text.



Mustang wrote:

Hi there,

I have two problems with some user forms i am trying to create.

Firstly the following code takes the entries from the data form into a
worksheet
ws.Cells(iRow, 2).Value = Me.txtstdt.Value
ws.Cells(iRow, 3).Value = Me.txtendt.Value

both txtstdt and txtendt are dates which are to be dd/mm/yy, however appear
on my worksheet as mm/dd/yy. Can anyone help me format them correctly? The
code appears to overwrite the cell formatting.

Secondly I have a job number layed out as 12-3456 which is entered into a
form and this code puts it into another worksheet

ws.Cells(iRow, 1).Value = Me.txtjobno.Value

My problem here is that it formats it as a date even though my worksheet
formattin is and should be set to general.

Any ideas very welcome!

Thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default User Forms and Date Formats

Thank you for your response.

I have tried the following (my VB knowledge is minimal)...

ws.Cells(iRow, 2).Value = Me.txtstdt.Value
With ws.Cells(iRow, 2).NumberFormat = "mm,dd,yyyy"
End With
ws.Cells(iRow, 3).Value = Me.txtendt.Value
With ws.Cells(iRow, 3).NumberFormat = "mm,dd,yyyy"
End With
and it still does not work. I am not sure I have put the code in correctly.

Thanks

"Dave Peterson" wrote:

with ws.Cells(iRow, 2)
'just an unambiguous date for testing, change it when you're happy it's ok
.numberformat = "mmmm dd, yyyy"

'cdate() uses the windows setting (mdy order) for the user
'and that may not be what you (the developer) expects!
.Value = cdate(Me.txtstdt.Value)
end with

And I'd just format that other cell as text first.

with ws.Cells(iRow, 1)
.numberformat = "@"
.Value = Me.txtjobno.Value
end with

or start the entry with an apostrophe:
ws.Cells(iRow, 1).Value = "'" & Me.txtjobno.Value
so that it would be entered as text.



Mustang wrote:

Hi there,

I have two problems with some user forms i am trying to create.

Firstly the following code takes the entries from the data form into a
worksheet
ws.Cells(iRow, 2).Value = Me.txtstdt.Value
ws.Cells(iRow, 3).Value = Me.txtendt.Value

both txtstdt and txtendt are dates which are to be dd/mm/yy, however appear
on my worksheet as mm/dd/yy. Can anyone help me format them correctly? The
code appears to overwrite the cell formatting.

Secondly I have a job number layed out as 12-3456 which is entered into a
form and this code puts it into another worksheet

ws.Cells(iRow, 1).Value = Me.txtjobno.Value

My problem here is that it formats it as a date even though my worksheet
formattin is and should be set to general.

Any ideas very welcome!

Thanks


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default User Forms and Date Formats

Try using the suggested code as written.

Just replace your existing single line with that group of 4.

Then it's almost the same for the second textbox.

Mustang wrote:

Thank you for your response.

I have tried the following (my VB knowledge is minimal)...

ws.Cells(iRow, 2).Value = Me.txtstdt.Value
With ws.Cells(iRow, 2).NumberFormat = "mm,dd,yyyy"
End With
ws.Cells(iRow, 3).Value = Me.txtendt.Value
With ws.Cells(iRow, 3).NumberFormat = "mm,dd,yyyy"
End With
and it still does not work. I am not sure I have put the code in correctly.

Thanks

"Dave Peterson" wrote:

with ws.Cells(iRow, 2)
'just an unambiguous date for testing, change it when you're happy it's ok
.numberformat = "mmmm dd, yyyy"

'cdate() uses the windows setting (mdy order) for the user
'and that may not be what you (the developer) expects!
.Value = cdate(Me.txtstdt.Value)
end with

And I'd just format that other cell as text first.

with ws.Cells(iRow, 1)
.numberformat = "@"
.Value = Me.txtjobno.Value
end with

or start the entry with an apostrophe:
ws.Cells(iRow, 1).Value = "'" & Me.txtjobno.Value
so that it would be entered as text.



Mustang wrote:

Hi there,

I have two problems with some user forms i am trying to create.

Firstly the following code takes the entries from the data form into a
worksheet
ws.Cells(iRow, 2).Value = Me.txtstdt.Value
ws.Cells(iRow, 3).Value = Me.txtendt.Value

both txtstdt and txtendt are dates which are to be dd/mm/yy, however appear
on my worksheet as mm/dd/yy. Can anyone help me format them correctly? The
code appears to overwrite the cell formatting.

Secondly I have a job number layed out as 12-3456 which is entered into a
form and this code puts it into another worksheet

ws.Cells(iRow, 1).Value = Me.txtjobno.Value

My problem here is that it formats it as a date even though my worksheet
formattin is and should be set to general.

Any ideas very welcome!

Thanks


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default User Forms and Date Formats


That is great, thanks very much for your help.


"Dave Peterson" wrote:

Try using the suggested code as written.

Just replace your existing single line with that group of 4.

Then it's almost the same for the second textbox.

Mustang wrote:

Thank you for your response.

I have tried the following (my VB knowledge is minimal)...

ws.Cells(iRow, 2).Value = Me.txtstdt.Value
With ws.Cells(iRow, 2).NumberFormat = "mm,dd,yyyy"
End With
ws.Cells(iRow, 3).Value = Me.txtendt.Value
With ws.Cells(iRow, 3).NumberFormat = "mm,dd,yyyy"
End With
and it still does not work. I am not sure I have put the code in correctly.

Thanks

"Dave Peterson" wrote:

with ws.Cells(iRow, 2)
'just an unambiguous date for testing, change it when you're happy it's ok
.numberformat = "mmmm dd, yyyy"

'cdate() uses the windows setting (mdy order) for the user
'and that may not be what you (the developer) expects!
.Value = cdate(Me.txtstdt.Value)
end with

And I'd just format that other cell as text first.

with ws.Cells(iRow, 1)
.numberformat = "@"
.Value = Me.txtjobno.Value
end with

or start the entry with an apostrophe:
ws.Cells(iRow, 1).Value = "'" & Me.txtjobno.Value
so that it would be entered as text.



Mustang wrote:

Hi there,

I have two problems with some user forms i am trying to create.

Firstly the following code takes the entries from the data form into a
worksheet
ws.Cells(iRow, 2).Value = Me.txtstdt.Value
ws.Cells(iRow, 3).Value = Me.txtendt.Value

both txtstdt and txtendt are dates which are to be dd/mm/yy, however appear
on my worksheet as mm/dd/yy. Can anyone help me format them correctly? The
code appears to overwrite the cell formatting.

Secondly I have a job number layed out as 12-3456 which is entered into a
form and this code puts it into another worksheet

ws.Cells(iRow, 1).Value = Me.txtjobno.Value

My problem here is that it formats it as a date even though my worksheet
formattin is and should be set to general.

Any ideas very welcome!

Thanks

--

Dave Peterson


--

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
User Forms Matthew Balch[_2_] Excel Programming 4 October 26th 06 05:01 PM
User forms help mav93[_6_] Excel Programming 2 March 2nd 06 08:47 PM
Text, Number and Date formats excel 2003 driving experienced user E F Bat Excel Discussion (Misc queries) 1 January 6th 06 07:10 PM
User Forms Gilly Hampshire Excel Programming 3 May 19th 05 02:58 PM
User Forms - Max Me Dave Peterson[_3_] Excel Programming 0 June 26th 04 04:22 AM


All times are GMT +1. The time now is 05:59 PM.

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

About Us

"It's about Microsoft Excel"