imperium1980
New Member
- Joined
- Feb 10, 2009
- Messages
- 27
Hi all,
I have put a macro together that pulls data from a sheet which has a date column formatted in standard UK dd/mm/yyyy. Whenever I run the macro it pulls my data together and dumps it into a new sheet called 'Summary' Everything is working fine except VB changes my dates to American formats, i.e 02/01/2012 (2nd Jan) becomes 01/02/2012 (1st Feb). This is driving me nuts! Any ideas how I get around this?
Option Explicit
DefInt I-M
DefStr S
Sub Summary()
Dim i, j, k, l, m, iDays
Dim sSummary(), sDate, sMC, sStyle, sPack
Select Case ActiveSheet.Name
Case "January", "March", "May", "July", "August", "October", "December"
iDays = 31
Case "February"
iDays = 29
Case Else
iDays = 30
End Select
l = 0
Range("E7").Select
For i = 0 To iDays - 1
sDate = ActiveCell.Offset(-5, i)
sMC = ActiveCell.Offset(-4, i)
sStyle = ActiveCell.Offset(-3, i)
sPack = ActiveCell.Offset(-2, i)
For j = 0 To 26
If ActiveCell.Offset(j, i) <> "" Then
ReDim Preserve sSummary(7, l)
sSummary(0, l) = sDate
sSummary(1, l) = sMC
sSummary(2, l) = sStyle
sSummary(3, l) = sPack
For m = 4 To 6
'MsgBox ActiveCell.Offset(j, m - 7)
sSummary(m, l) = ActiveCell.Offset(j, m - 7)
Next
sSummary(7, l) = ActiveCell.Offset(j, i)
l = l + 1
End If
Next
Next
Sheets("New Summary").Select
Range("A2").Select
Do
If ActiveCell <> "" Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until ActiveCell = ""
For j = 0 To l - 1
For i = 0 To 7
ActiveCell.Offset(j, i) = sSummary(i, j)
Next
Next
End Sub
I have put a macro together that pulls data from a sheet which has a date column formatted in standard UK dd/mm/yyyy. Whenever I run the macro it pulls my data together and dumps it into a new sheet called 'Summary' Everything is working fine except VB changes my dates to American formats, i.e 02/01/2012 (2nd Jan) becomes 01/02/2012 (1st Feb). This is driving me nuts! Any ideas how I get around this?
Option Explicit
DefInt I-M
DefStr S
Sub Summary()
Dim i, j, k, l, m, iDays
Dim sSummary(), sDate, sMC, sStyle, sPack
Select Case ActiveSheet.Name
Case "January", "March", "May", "July", "August", "October", "December"
iDays = 31
Case "February"
iDays = 29
Case Else
iDays = 30
End Select
l = 0
Range("E7").Select
For i = 0 To iDays - 1
sDate = ActiveCell.Offset(-5, i)
sMC = ActiveCell.Offset(-4, i)
sStyle = ActiveCell.Offset(-3, i)
sPack = ActiveCell.Offset(-2, i)
For j = 0 To 26
If ActiveCell.Offset(j, i) <> "" Then
ReDim Preserve sSummary(7, l)
sSummary(0, l) = sDate
sSummary(1, l) = sMC
sSummary(2, l) = sStyle
sSummary(3, l) = sPack
For m = 4 To 6
'MsgBox ActiveCell.Offset(j, m - 7)
sSummary(m, l) = ActiveCell.Offset(j, m - 7)
Next
sSummary(7, l) = ActiveCell.Offset(j, i)
l = l + 1
End If
Next
Next
Sheets("New Summary").Select
Range("A2").Select
Do
If ActiveCell <> "" Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until ActiveCell = ""
For j = 0 To l - 1
For i = 0 To 7
ActiveCell.Offset(j, i) = sSummary(i, j)
Next
Next
End Sub