LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Recurring problem - user input date from messagebox doesn't get formatted correctly in secondary cells.

I recvd the fabulous code below some time back for prompting users for
dates which then gets dumped into the sheet. I've modified it several
times and use it throughout several workbooks now and it usu. works
perfectly.

However, in cases where cells are dependent on 2 different versions of
the date differentiated by cell formatting re the date display, the
format in secondary cell doesn't display properlly as per that cell's
formatting. In the case today, it displays exactly the same as in the
first cell.

----------------------------------------------------------------------
Sub NewDate()
'
ActiveSheet.Unprotect 'place at the beginning of the code
On Error Resume Next
ActiveSheet.ShowAllData
On Error GoTo 0

Dim vResponse As Variant
Do
vResponse = Application.InputBox( _
Prompt:="Enter a start date." & vbCrLf & vbCrLf & _
"(By the way, Excel is pretty forgiving of the date
style you use when you enter that date.)", _
Title:="Thyroid Log", _
Default:=Format(Date, "yyyy/mm/dd"), _
Type:=2)
If vResponse = False Then Exit Sub 'User cancelled
Loop Until IsDate(vResponse)
Range("B2").Value = Format(CDate(vResponse), "yyyy/mm/dd")
ActiveSheet.Protect 'place at the end of the code
End Sub
----------------------------------------------------------------------

So, B2 user input date gets dumped as yyyy.mm.dd.ddd in B2 which is
how the cell is formatted. Perfect.

B1 is supposed to take the value of B2 but formatted as ddd; however,
I'm getting the same date display as in B2 - yyyy.mm.dd.ddd instead of
ddd. If I re-enter the exact date manually that was just dumped into
the cell by the above code, _then_ the cell displays the ddd format
correctly (??).

Can this be resolved? It's only the one cell that is not working.
All the rest of the sheet seems fine.

Thank you! :oD

 
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
CF -- User input date range jujube Excel Programming 0 December 27th 05 08:45 PM
Date Formatted Cells Mike Excel Worksheet Functions 3 December 3rd 04 05:55 PM
VBA: Look-Up Cell Date From User Input Box and return ALL matches Mcasteel[_38_] Excel Programming 1 November 11th 04 03:34 AM
User Form/Input box problem Peter[_39_] Excel Programming 1 April 21st 04 10:37 PM
Messagebox: Alert user Worksheet is Unprotected Maria[_6_] Excel Programming 4 November 5th 03 04:34 AM


All times are GMT +1. The time now is 04:07 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"