Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Excel changing date format after VB has run

Hi

I have a sheet 1 with a combo box and a blank field. When something
is selected from the combo box a date gets populated in the blank
field. The date is custom formatted as mmm-yyyy.

On sheet 2 I have a table with the options in the drop down box and a
date next to them. When a selection is done, the code does a VLOOKUP
and populates the data in Sheet 1 in the blank field. Dates are also
mmm-yyyy in the Sheet 2.

The problem is, say the date in Sheet 2 is 01/12/2010 displayed as
Dec-2010. When it is put into sheet w, it flips it to 12/01/2010 so
says Jan-2010. Any idea why this is happening please?

Code Below - VersionRange is a named Range ($C$4:$F$56) in Sheet 2

Dim boxdate
Dim VerValue
Dim VerRange
Dim ws As Worksheet

Set ws = Worksheets("Sheet 2")
VerValue = Combo1.Text
VerRange = ws.Range("VersionRange")

If VerValue = "" Then
boxdate= ""
Else: boxdate = Application.WorksheetFunction.VLookup(VerValue,
VerRange, 2)
End If

Range("A19").Select
ActiveCell.FormulaR1C1 = boxdate


Thank you

Rich
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Excel changing date format after VB has run

Also, I have tried changing the fields to text but then the VLOOKUP
wont work.
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Excel changing date format after VB has run

I'd try:

with Range("A19")
'an unambiguous date format for testing
.numberformat = "mmmm dd, yyyy"
.value = clng(boxdate)
end with


Richhall wrote:

Hi

I have a sheet 1 with a combo box and a blank field. When something
is selected from the combo box a date gets populated in the blank
field. The date is custom formatted as mmm-yyyy.

On sheet 2 I have a table with the options in the drop down box and a
date next to them. When a selection is done, the code does a VLOOKUP
and populates the data in Sheet 1 in the blank field. Dates are also
mmm-yyyy in the Sheet 2.

The problem is, say the date in Sheet 2 is 01/12/2010 displayed as
Dec-2010. When it is put into sheet w, it flips it to 12/01/2010 so
says Jan-2010. Any idea why this is happening please?

Code Below - VersionRange is a named Range ($C$4:$F$56) in Sheet 2

Dim boxdate
Dim VerValue
Dim VerRange
Dim ws As Worksheet

Set ws = Worksheets("Sheet 2")
VerValue = Combo1.Text
VerRange = ws.Range("VersionRange")

If VerValue = "" Then
boxdate= ""
Else: boxdate = Application.WorksheetFunction.VLookup(VerValue,
VerRange, 2)
End If

Range("A19").Select
ActiveCell.FormulaR1C1 = boxdate

Thank you

Rich


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Excel changing date format after VB has run

Seems it was something to do with the VLOOKUP, dates are fine now as I
added:

Set VerRange = Worksheets("Sheet 2").Range("VersionRange")

Everything seemed to start working ok.

Thanks anyway. Eventually I just added the VLOOKUP into the cell
using an Admin sheet with the VerValue set in a cell there.

Cheers

Rich
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
Changing the date format on the date table in a chart spudsnruf Charts and Charting in Excel 2 September 3rd 09 07:08 PM
Excel 2003 - Changing Date Format oceanmist Excel Discussion (Misc queries) 3 August 2nd 07 07:59 PM
Excel 2002 - Date format keeps changing B. Levien Excel Discussion (Misc queries) 0 February 6th 06 09:35 PM
Changing to date format Peretz Stern Excel Discussion (Misc queries) 6 December 29th 05 08:13 PM
excel is changing date format hubbo Setting up and Configuration of Excel 1 May 18th 05 08:07 PM


All times are GMT +1. The time now is 06:36 AM.

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"