A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

sorting dates in another sheet



 
 
Thread Tools Display Modes
  #1  
Old August 23rd, 2009, 02:54 PM posted to microsoft.public.excel.misc
BARRY
external usenet poster
 
Posts: 383
Default sorting dates in another sheet

Hi, I wonder if any one can help I have a sheet that has rows of dates in
that look like this
31 October 2009 26 December 2009 20 February 2010
There are several rows and they are all have a persons name in the first
cell A1 and a start date in the next A2, the other rows are populated with
dates in two monthly intervals now because the start dates are all different
they are really hard to read each month, What I would like to do is open a
new sheet ( call it dates in order) and have 13 columns first one with a list
of names and then the next 12 the months of the year, then I would like to
transfer all the dates for January 2009 from the first sheet into the column
headed January against the original name that is was linked to in the first
sheet and so on, I would then make another sheet for 2010. I hope this makes
sense, Can it be done?

Thanks in advance , Barry.

  #2  
Old August 23rd, 2009, 04:04 PM posted to microsoft.public.excel.misc
Joel
external usenet poster
 
Posts: 2,855
Default sorting dates in another sheet

You'll need a macro. it is pretty easy to write one but I would like you to
post some sample row of the data. Your explanation doesn't clearly specify
everything I would need to write the macro.

"Barry" wrote:

Hi, I wonder if any one can help I have a sheet that has rows of dates in
that look like this
31 October 2009 26 December 2009 20 February 2010
There are several rows and they are all have a persons name in the first
cell A1 and a start date in the next A2, the other rows are populated with
dates in two monthly intervals now because the start dates are all different
they are really hard to read each month, What I would like to do is open a
new sheet ( call it dates in order) and have 13 columns first one with a list
of names and then the next 12 the months of the year, then I would like to
transfer all the dates for January 2009 from the first sheet into the column
headed January against the original name that is was linked to in the first
sheet and so on, I would then make another sheet for 2010. I hope this makes
sense, Can it be done?

Thanks in advance , Barry.

  #3  
Old August 23rd, 2009, 07:59 PM posted to microsoft.public.excel.misc
BARRY
external usenet poster
 
Posts: 383
Default sorting dates in another sheet

Hi, Joel, Sorry about the delay replying the site said the questions option
was not working so I did not relise it had been posted, what I have is a
sheet ( I can call it master) in cell a2 is a list of names then in b2 a
start date then each cell after that is 56 days after the cell before, what I
would like to do is look at all the dates in row 2 and copy any dates that
are in january into another sheet (call it sorted dates) in the other sheet
cell a2 would be a copy of the name from a2 in the (master) then in b2
(sorted dates) I would like copy any dates from row b2 to z2 that are January
2008 and in c2 Febuary 2009 from the same range in the master sheet and so on
to December 2009 both sheets have names listed down to row 12.

"Joel" wrote:

You'll need a macro. it is pretty easy to write one but I would like you to
post some sample row of the data. Your explanation doesn't clearly specify
everything I would need to write the macro.

"Barry" wrote:

Hi, I wonder if any one can help I have a sheet that has rows of dates in
that look like this
31 October 2009 26 December 2009 20 February 2010
There are several rows and they are all have a persons name in the first
cell A1 and a start date in the next A2, the other rows are populated with
dates in two monthly intervals now because the start dates are all different
they are really hard to read each month, What I would like to do is open a
new sheet ( call it dates in order) and have 13 columns first one with a list
of names and then the next 12 the months of the year, then I would like to
transfer all the dates for January 2009 from the first sheet into the column
headed January against the original name that is was linked to in the first
sheet and so on, I would then make another sheet for 2010. I hope this makes
sense, Can it be done?

Thanks in advance , Barry.

  #4  
Old August 23rd, 2009, 08:41 PM posted to microsoft.public.excel.misc
BARRY
external usenet poster
 
Posts: 383
Default sorting dates in another sheet

19 June 2008 14 August 2008 09 October 2008 04 December 2008
13 July 2008 07 September 2008 02 November 2008 28 December
13 December 2007 07 February 2008 03 April 2008 29 May2008
This is how the dates comes in, this is three rows , I would like to copy and
sort in another sheet, so all the junes from the three rows are in one
column, so if it is column b then b1 would have any june dates from the first
row, b2 would have any june dates from the second row and so on.


"Joel" wrote:

You'll need a macro. it is pretty easy to write one but I would like you to
post some sample row of the data. Your explanation doesn't clearly specify
everything I would need to write the macro.

"Barry" wrote:

Hi, I wonder if any one can help I have a sheet that has rows of dates in
that look like this
31 October 2009 26 December 2009 20 February 2010
There are several rows and they are all have a persons name in the first
cell A1 and a start date in the next A2, the other rows are populated with
dates in two monthly intervals now because the start dates are all different
they are really hard to read each month, What I would like to do is open a
new sheet ( call it dates in order) and have 13 columns first one with a list
of names and then the next 12 the months of the year, then I would like to
transfer all the dates for January 2009 from the first sheet into the column
headed January against the original name that is was linked to in the first
sheet and so on, I would then make another sheet for 2010. I hope this makes
sense, Can it be done?

Thanks in advance , Barry.

  #5  
Old August 23rd, 2009, 09:04 PM posted to microsoft.public.excel.misc
Joel
external usenet poster
 
Posts: 2,855
Default sorting dates in another sheet

It looks like Gord answer your question in another posting.

"Barry" wrote:

19 June 2008 14 August 2008 09 October 2008 04 December 2008
13 July 2008 07 September 2008 02 November 2008 28 December
13 December 2007 07 February 2008 03 April 2008 29 May2008
This is how the dates comes in, this is three rows , I would like to copy and
sort in another sheet, so all the junes from the three rows are in one
column, so if it is column b then b1 would have any june dates from the first
row, b2 would have any june dates from the second row and so on.


"Joel" wrote:

You'll need a macro. it is pretty easy to write one but I would like you to
post some sample row of the data. Your explanation doesn't clearly specify
everything I would need to write the macro.

"Barry" wrote:

Hi, I wonder if any one can help I have a sheet that has rows of dates in
that look like this
31 October 2009 26 December 2009 20 February 2010
There are several rows and they are all have a persons name in the first
cell A1 and a start date in the next A2, the other rows are populated with
dates in two monthly intervals now because the start dates are all different
they are really hard to read each month, What I would like to do is open a
new sheet ( call it dates in order) and have 13 columns first one with a list
of names and then the next 12 the months of the year, then I would like to
transfer all the dates for January 2009 from the first sheet into the column
headed January against the original name that is was linked to in the first
sheet and so on, I would then make another sheet for 2010. I hope this makes
sense, Can it be done?

Thanks in advance , Barry.

  #6  
Old August 23rd, 2009, 09:47 PM posted to microsoft.public.excel.misc
BARRY
external usenet poster
 
Posts: 383
Default sorting dates in another sheet

Yes I thought it did but the columns are still mixed up which ever way I
tried it, either sort by row or column, it still did not put all Januray in
the first column and all the febuary in thr next and so on.

"Joel" wrote:

It looks like Gord answer your question in another posting.

"Barry" wrote:

19 June 2008 14 August 2008 09 October 2008 04 December 2008
13 July 2008 07 September 2008 02 November 2008 28 December
13 December 2007 07 February 2008 03 April 2008 29 May2008
This is how the dates comes in, this is three rows , I would like to copy and
sort in another sheet, so all the junes from the three rows are in one
column, so if it is column b then b1 would have any june dates from the first
row, b2 would have any june dates from the second row and so on.


"Joel" wrote:

You'll need a macro. it is pretty easy to write one but I would like you to
post some sample row of the data. Your explanation doesn't clearly specify
everything I would need to write the macro.

"Barry" wrote:

Hi, I wonder if any one can help I have a sheet that has rows of dates in
that look like this
31 October 2009 26 December 2009 20 February 2010
There are several rows and they are all have a persons name in the first
cell A1 and a start date in the next A2, the other rows are populated with
dates in two monthly intervals now because the start dates are all different
they are really hard to read each month, What I would like to do is open a
new sheet ( call it dates in order) and have 13 columns first one with a list
of names and then the next 12 the months of the year, then I would like to
transfer all the dates for January 2009 from the first sheet into the column
headed January against the original name that is was linked to in the first
sheet and so on, I would then make another sheet for 2010. I hope this makes
sense, Can it be done?

Thanks in advance , Barry.

  #7  
Old August 24th, 2009, 01:29 AM posted to microsoft.public.excel.misc
Joel
external usenet poster
 
Posts: 2,855
Default sorting dates in another sheet

I wrote 2 macros. One to create the worksheets. the 2nd to put data into
the worksheets.

Sub createsheets()

StartYear = InputBox("Enter start year : ")
EndYear = InputBox("Enter end year : ")
For MyYears = StartYear To EndYear
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = MyYears
For MyMonth = 1 To 12
Cells(1, MyMonth + 1) = MonthName(MyMonth)
Next MyMonth
Next MyYears

End Sub

Sub MoveDates()

With Sheets("Sheet1")
RowCount = 1
Do While .Range("A" & RowCount) ""
Employee = .Range("A" & RowCount)
ColCount = 2
Do While .Cells(RowCount, ColCount) ""
MyDate = .Cells(RowCount, ColCount)
MyYear = Year(MyDate)
MyMonth = Month(MyDate)
With Sheets(CStr(MyYear))
'check if employee already exists
Set c = .Columns("A").Find(what:=Employee, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
NewRow = LastRow + 1
.Cells(NewRow, MyMonth + 1) = MyDate
.Cells(NewRow, MyMonth + 1).NumberFormat = _
"DD MMMM YYYY"
Else
.Cells(c.Row, MyMonth + 1) = MyDate
.Cells(c.Row, MyMonth + 1).NumberFormat = _
"DD MMMM YYYY"
End If
End With
ColCount = ColCount + 1
Loop
RowCount = RowCount + 1
Loop
End With

End Sub


"Barry" wrote:

Yes I thought it did but the columns are still mixed up which ever way I
tried it, either sort by row or column, it still did not put all Januray in
the first column and all the febuary in thr next and so on.

"Joel" wrote:

It looks like Gord answer your question in another posting.

"Barry" wrote:

19 June 2008 14 August 2008 09 October 2008 04 December 2008
13 July 2008 07 September 2008 02 November 2008 28 December
13 December 2007 07 February 2008 03 April 2008 29 May2008
This is how the dates comes in, this is three rows , I would like to copy and
sort in another sheet, so all the junes from the three rows are in one
column, so if it is column b then b1 would have any june dates from the first
row, b2 would have any june dates from the second row and so on.


"Joel" wrote:

You'll need a macro. it is pretty easy to write one but I would like you to
post some sample row of the data. Your explanation doesn't clearly specify
everything I would need to write the macro.

"Barry" wrote:

Hi, I wonder if any one can help I have a sheet that has rows of dates in
that look like this
31 October 2009 26 December 2009 20 February 2010
There are several rows and they are all have a persons name in the first
cell A1 and a start date in the next A2, the other rows are populated with
dates in two monthly intervals now because the start dates are all different
they are really hard to read each month, What I would like to do is open a
new sheet ( call it dates in order) and have 13 columns first one with a list
of names and then the next 12 the months of the year, then I would like to
transfer all the dates for January 2009 from the first sheet into the column
headed January against the original name that is was linked to in the first
sheet and so on, I would then make another sheet for 2010. I hope this makes
sense, Can it be done?

Thanks in advance , Barry.

  #8  
Old August 24th, 2009, 02:06 AM posted to microsoft.public.excel.misc
BARRY
external usenet poster
 
Posts: 383
Default sorting dates in another sheet

Thank you Joel,Just to show my complete ignorance, where do I put the macros?

"Joel" wrote:

I wrote 2 macros. One to create the worksheets. the 2nd to put data into
the worksheets.

Sub createsheets()

StartYear = InputBox("Enter start year : ")
EndYear = InputBox("Enter end year : ")
For MyYears = StartYear To EndYear
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = MyYears
For MyMonth = 1 To 12
Cells(1, MyMonth + 1) = MonthName(MyMonth)
Next MyMonth
Next MyYears

End Sub

Sub MoveDates()

With Sheets("Sheet1")
RowCount = 1
Do While .Range("A" & RowCount) ""
Employee = .Range("A" & RowCount)
ColCount = 2
Do While .Cells(RowCount, ColCount) ""
MyDate = .Cells(RowCount, ColCount)
MyYear = Year(MyDate)
MyMonth = Month(MyDate)
With Sheets(CStr(MyYear))
'check if employee already exists
Set c = .Columns("A").Find(what:=Employee, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
NewRow = LastRow + 1
.Cells(NewRow, MyMonth + 1) = MyDate
.Cells(NewRow, MyMonth + 1).NumberFormat = _
"DD MMMM YYYY"
Else
.Cells(c.Row, MyMonth + 1) = MyDate
.Cells(c.Row, MyMonth + 1).NumberFormat = _
"DD MMMM YYYY"
End If
End With
ColCount = ColCount + 1
Loop
RowCount = RowCount + 1
Loop
End With

End Sub


"Barry" wrote:

Yes I thought it did but the columns are still mixed up which ever way I
tried it, either sort by row or column, it still did not put all Januray in
the first column and all the febuary in thr next and so on.

"Joel" wrote:

It looks like Gord answer your question in another posting.

"Barry" wrote:

19 June 2008 14 August 2008 09 October 2008 04 December 2008
13 July 2008 07 September 2008 02 November 2008 28 December
13 December 2007 07 February 2008 03 April 2008 29 May2008
This is how the dates comes in, this is three rows , I would like to copy and
sort in another sheet, so all the junes from the three rows are in one
column, so if it is column b then b1 would have any june dates from the first
row, b2 would have any june dates from the second row and so on.


"Joel" wrote:

You'll need a macro. it is pretty easy to write one but I would like you to
post some sample row of the data. Your explanation doesn't clearly specify
everything I would need to write the macro.

"Barry" wrote:

Hi, I wonder if any one can help I have a sheet that has rows of dates in
that look like this
31 October 2009 26 December 2009 20 February 2010
There are several rows and they are all have a persons name in the first
cell A1 and a start date in the next A2, the other rows are populated with
dates in two monthly intervals now because the start dates are all different
they are really hard to read each month, What I would like to do is open a
new sheet ( call it dates in order) and have 13 columns first one with a list
of names and then the next 12 the months of the year, then I would like to
transfer all the dates for January 2009 from the first sheet into the column
headed January against the original name that is was linked to in the first
sheet and so on, I would then make another sheet for 2010. I hope this makes
sense, Can it be done?

Thanks in advance , Barry.

  #9  
Old August 24th, 2009, 11:30 AM posted to microsoft.public.excel.misc
Joel
external usenet poster
 
Posts: 2,855
Default sorting dates in another sheet

From worksheet type ALT-F11 to get to VBA window

Add a new module from VBA menu Insert Module

Paste code into module sheet

Type Alt F11 to get back to worksheet.

Run macro from menu
Tools - Macro - Maros and choose the correct macro. Run the macro to create
the sheet first and only run the macro once. It will give you an error if
you run it twice since the worksheets already exist.


"Barry" wrote:

Thank you Joel,Just to show my complete ignorance, where do I put the macros?

"Joel" wrote:

I wrote 2 macros. One to create the worksheets. the 2nd to put data into
the worksheets.

Sub createsheets()

StartYear = InputBox("Enter start year : ")
EndYear = InputBox("Enter end year : ")
For MyYears = StartYear To EndYear
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = MyYears
For MyMonth = 1 To 12
Cells(1, MyMonth + 1) = MonthName(MyMonth)
Next MyMonth
Next MyYears

End Sub

Sub MoveDates()

With Sheets("Sheet1")
RowCount = 1
Do While .Range("A" & RowCount) ""
Employee = .Range("A" & RowCount)
ColCount = 2
Do While .Cells(RowCount, ColCount) ""
MyDate = .Cells(RowCount, ColCount)
MyYear = Year(MyDate)
MyMonth = Month(MyDate)
With Sheets(CStr(MyYear))
'check if employee already exists
Set c = .Columns("A").Find(what:=Employee, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
NewRow = LastRow + 1
.Cells(NewRow, MyMonth + 1) = MyDate
.Cells(NewRow, MyMonth + 1).NumberFormat = _
"DD MMMM YYYY"
Else
.Cells(c.Row, MyMonth + 1) = MyDate
.Cells(c.Row, MyMonth + 1).NumberFormat = _
"DD MMMM YYYY"
End If
End With
ColCount = ColCount + 1
Loop
RowCount = RowCount + 1
Loop
End With

End Sub


"Barry" wrote:

Yes I thought it did but the columns are still mixed up which ever way I
tried it, either sort by row or column, it still did not put all Januray in
the first column and all the febuary in thr next and so on.

"Joel" wrote:

It looks like Gord answer your question in another posting.

"Barry" wrote:

19 June 2008 14 August 2008 09 October 2008 04 December 2008
13 July 2008 07 September 2008 02 November 2008 28 December
13 December 2007 07 February 2008 03 April 2008 29 May2008
This is how the dates comes in, this is three rows , I would like to copy and
sort in another sheet, so all the junes from the three rows are in one
column, so if it is column b then b1 would have any june dates from the first
row, b2 would have any june dates from the second row and so on.


"Joel" wrote:

You'll need a macro. it is pretty easy to write one but I would like you to
post some sample row of the data. Your explanation doesn't clearly specify
everything I would need to write the macro.

"Barry" wrote:

Hi, I wonder if any one can help I have a sheet that has rows of dates in
that look like this
31 October 2009 26 December 2009 20 February 2010
There are several rows and they are all have a persons name in the first
cell A1 and a start date in the next A2, the other rows are populated with
dates in two monthly intervals now because the start dates are all different
they are really hard to read each month, What I would like to do is open a
new sheet ( call it dates in order) and have 13 columns first one with a list
of names and then the next 12 the months of the year, then I would like to
transfer all the dates for January 2009 from the first sheet into the column
headed January against the original name that is was linked to in the first
sheet and so on, I would then make another sheet for 2010. I hope this makes
sense, Can it be done?

Thanks in advance , Barry.

  #10  
Old August 24th, 2009, 08:39 PM posted to microsoft.public.excel.misc
BARRY
external usenet poster
 
Posts: 383
Default sorting dates in another sheet

I have loaded as advised and loaded the dates (01/01/09) and (31/12/09) it
has then come up with Run-time error `13`: Type mismatch, I pressed Debug
and it highlighted with an arrow
For MyYears = StartYear To EndYear.
What did I do wrong?


"Joel" wrote:

From worksheet type ALT-F11 to get to VBA window

Add a new module from VBA menu Insert Module

Paste code into module sheet

Type Alt F11 to get back to worksheet.

Run macro from menu
Tools - Macro - Maros and choose the correct macro. Run the macro to create
the sheet first and only run the macro once. It will give you an error if
you run it twice since the worksheets already exist.


"Barry" wrote:

Thank you Joel,Just to show my complete ignorance, where do I put the macros?

"Joel" wrote:

I wrote 2 macros. One to create the worksheets. the 2nd to put data into
the worksheets.

Sub createsheets()

StartYear = InputBox("Enter start year : ")
EndYear = InputBox("Enter end year : ")
For MyYears = StartYear To EndYear
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = MyYears
For MyMonth = 1 To 12
Cells(1, MyMonth + 1) = MonthName(MyMonth)
Next MyMonth
Next MyYears

End Sub

Sub MoveDates()

With Sheets("Sheet1")
RowCount = 1
Do While .Range("A" & RowCount) ""
Employee = .Range("A" & RowCount)
ColCount = 2
Do While .Cells(RowCount, ColCount) ""
MyDate = .Cells(RowCount, ColCount)
MyYear = Year(MyDate)
MyMonth = Month(MyDate)
With Sheets(CStr(MyYear))
'check if employee already exists
Set c = .Columns("A").Find(what:=Employee, _
LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
NewRow = LastRow + 1
.Cells(NewRow, MyMonth + 1) = MyDate
.Cells(NewRow, MyMonth + 1).NumberFormat = _
"DD MMMM YYYY"
Else
.Cells(c.Row, MyMonth + 1) = MyDate
.Cells(c.Row, MyMonth + 1).NumberFormat = _
"DD MMMM YYYY"
End If
End With
ColCount = ColCount + 1
Loop
RowCount = RowCount + 1
Loop
End With

End Sub


"Barry" wrote:

Yes I thought it did but the columns are still mixed up which ever way I
tried it, either sort by row or column, it still did not put all Januray in
the first column and all the febuary in thr next and so on.

"Joel" wrote:

It looks like Gord answer your question in another posting.

"Barry" wrote:

19 June 2008 14 August 2008 09 October 2008 04 December 2008
13 July 2008 07 September 2008 02 November 2008 28 December
13 December 2007 07 February 2008 03 April 2008 29 May2008
This is how the dates comes in, this is three rows , I would like to copy and
sort in another sheet, so all the junes from the three rows are in one
column, so if it is column b then b1 would have any june dates from the first
row, b2 would have any june dates from the second row and so on.


"Joel" wrote:

You'll need a macro. it is pretty easy to write one but I would like you to
post some sample row of the data. Your explanation doesn't clearly specify
everything I would need to write the macro.

"Barry" wrote:

Hi, I wonder if any one can help I have a sheet that has rows of dates in
that look like this
31 October 2009 26 December 2009 20 February 2010
There are several rows and they are all have a persons name in the first
cell A1 and a start date in the next A2, the other rows are populated with
dates in two monthly intervals now because the start dates are all different
they are really hard to read each month, What I would like to do is open a
new sheet ( call it dates in order) and have 13 columns first one with a list
of names and then the next 12 the months of the year, then I would like to
transfer all the dates for January 2009 from the first sheet into the column
headed January against the original name that is was linked to in the first
sheet and so on, I would then make another sheet for 2010. I hope this makes
sense, Can it be done?

Thanks in advance , Barry.

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:24 AM.


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