PC Review


Reply
Thread Tools Rate Thread

Date format converted from UK to US format

 
 
Richard
Guest
Posts: n/a
 
      8th Dec 2009
I have a workbook with multiple tabs, each of which take data from mutlipe
spreadsheets using a Query. I then use the code below, to consolidate all the
data on the tabs into one table, so i can PivotReport on it. The problem
comes from the columns with dates in it - they import using the Query in UK
format, but after the code has brought the tabs into one, they become US
format as text. Can anyone help correct this, as i'm having to use a
workaround formula to rearrange the cells at the moment.

Sub collate2()
Dim firstRow As Double, lastRow As Double, srcRng As Range, destRng As
Range, ws As Worksheet
firstRow = 2
For Each ws In Sheets
'goes through the workbook grabbing data, if the sheet isn't called
"orders"
With ws
If LCase(.Name) <> "analysis" Then
'finds last used row by selecting last row and simulating
ctrl-up arrow
lastRow = .Cells(Rows.Count, "B").End(xlUp).Row
If lastRow >= firstRow Then 'makes sure there's some data to
copy
'gets range of data in current sheet
Set srcRng = .Range(.Cells(firstRow, "A"),
..Cells(lastRow, "AL"))
'gets range of first cell on row below data already on
sheet
Set destRng = Sheets("MasterSheet").Cells(Rows.Count,
"B").End(xlUp).Resize(lastRow - firstRow + 1, 40).Offset(1, -1)
destRng.Value = srcRng.Value
End If
End If
End With
Next ws
End Sub
--
Richard
 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      8th Dec 2009
If they are coming in as "text", then what do these dates look like as
"text"... 12/8/2009, December 8 2009, 8Dec09, something else? I would think
the plan could be to parse the date text you have (after knowing its format)
into its month, day and year and put those pieces into the proper argument
location in the DateSerial function to create a date in you given system,
then assign that date to your cell.

--
Rick (MVP - Excel)


"Richard" <(E-Mail Removed)> wrote in message
news:921BE710-A095-482F-A525-(E-Mail Removed)...
>I have a workbook with multiple tabs, each of which take data from mutlipe
> spreadsheets using a Query. I then use the code below, to consolidate all
> the
> data on the tabs into one table, so i can PivotReport on it. The problem
> comes from the columns with dates in it - they import using the Query in
> UK
> format, but after the code has brought the tabs into one, they become US
> format as text. Can anyone help correct this, as i'm having to use a
> workaround formula to rearrange the cells at the moment.
>
> Sub collate2()
> Dim firstRow As Double, lastRow As Double, srcRng As Range, destRng As
> Range, ws As Worksheet
> firstRow = 2
> For Each ws In Sheets
> 'goes through the workbook grabbing data, if the sheet isn't called
> "orders"
> With ws
> If LCase(.Name) <> "analysis" Then
> 'finds last used row by selecting last row and simulating
> ctrl-up arrow
> lastRow = .Cells(Rows.Count, "B").End(xlUp).Row
> If lastRow >= firstRow Then 'makes sure there's some data
> to
> copy
> 'gets range of data in current sheet
> Set srcRng = .Range(.Cells(firstRow, "A"),
> .Cells(lastRow, "AL"))
> 'gets range of first cell on row below data already on
> sheet
> Set destRng = Sheets("MasterSheet").Cells(Rows.Count,
> "B").End(xlUp).Resize(lastRow - firstRow + 1, 40).Offset(1, -1)
> destRng.Value = srcRng.Value
> End If
> End If
> End With
> Next ws
> End Sub
> --
> Richard


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      8th Dec 2009
Just to add to Rick's notes...

The problem I've had with stuff like this is that some dates come as text--and
others come in as dates--just the wrong dates.

12/31/2009 looks like a date in my USA settings and is brought in as Dec 31,
2009.

31/12/2009 doesn't look like a date in my USA settings and is brought in as
text.

But the problem is these kind of things...

06/07/2009 It looks like a date and is brought in as Jun 7, 2009. But the real
value for this date is July 6, 2009.

So if I convert the "text dates" to real dates, I've still got all those real
dates that don't reflect what they should.

If it's at all possible, I'd try to bring this data in as text--and then parse
it myself.



Richard wrote:
>
> I have a workbook with multiple tabs, each of which take data from mutlipe
> spreadsheets using a Query. I then use the code below, to consolidate all the
> data on the tabs into one table, so i can PivotReport on it. The problem
> comes from the columns with dates in it - they import using the Query in UK
> format, but after the code has brought the tabs into one, they become US
> format as text. Can anyone help correct this, as i'm having to use a
> workaround formula to rearrange the cells at the moment.
>
> Sub collate2()
> Dim firstRow As Double, lastRow As Double, srcRng As Range, destRng As
> Range, ws As Worksheet
> firstRow = 2
> For Each ws In Sheets
> 'goes through the workbook grabbing data, if the sheet isn't called
> "orders"
> With ws
> If LCase(.Name) <> "analysis" Then
> 'finds last used row by selecting last row and simulating
> ctrl-up arrow
> lastRow = .Cells(Rows.Count, "B").End(xlUp).Row
> If lastRow >= firstRow Then 'makes sure there's some data to
> copy
> 'gets range of data in current sheet
> Set srcRng = .Range(.Cells(firstRow, "A"),
> .Cells(lastRow, "AL"))
> 'gets range of first cell on row below data already on
> sheet
> Set destRng = Sheets("MasterSheet").Cells(Rows.Count,
> "B").End(xlUp).Resize(lastRow - firstRow + 1, 40).Offset(1, -1)
> destRng.Value = srcRng.Value
> End If
> End If
> End With
> Next ws
> End Sub
> --
> Richard


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Number formsts converted to date format nupnin Microsoft Excel Crashes 6 23rd Sep 2009 04:50 PM
when loading csv file to Excel, cells get converted to date format =?Utf-8?B?UkI=?= Microsoft Excel Misc 3 14th Feb 2007 07:54 AM
How do I create list validation from code without the text being converted into date format? EG Microsoft Excel Programming 2 24th Nov 2005 10:16 AM
Can a indexed pixel format be converted to some other format? **Developer** Microsoft VB .NET 8 31st Oct 2005 02:36 AM
Application originally in Acc2000 format, when converted to AccXP format, keeps growing... Nuno Almeida Microsoft Access 2 23rd May 2004 11:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:21 AM.