#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 116
Default sorting cells

Hi, I wonder if any one can help, I have a grid of dates between €œY4 and
AD19€ (in a spread sheet) what I would like to do is make 12 columns headed
Jan €“Dec and find all dates that are January from the grid and place them in
the column headed Jan, so if the date is in row 4 in the grid it would go in
row 4 in the column headed Jan and the same with the columns headed Feb. to
Dec.
I dont know if this is possible, it may be a fun challenge for some one.
Thank you, Barry.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default sorting cells

This macro does the job, if Jan €“Dec columns are columns A:L:

Sub test()
Dim datesrng As Range, dcell As Range
Set datesrng = Range("Y4:AD19")
Dim mcounter(12)
For mc = 0 To 11
mcounter(mc) = 0
Next mc
For Each dcell In datesrng
destcol = Month(dcell.Value)
mcounter(destcol - 1) = mcounter(destcol - 1) + 1
Cells(mcounter(destcol - 1), destcol).Value = dcell.Value
Next dcell
End Sub

Except:
if the date is in row 4 in the grid it would go in
row 4 in the column headed Jan


Where do you want to to place the next date in row 4 in the grid if it is
also a Jan date?

Regards,
Stefi

€žbarry€ ezt Γ*rta:

Hi, I wonder if any one can help, I have a grid of dates between €œY4 and
AD19€ (in a spread sheet) what I would like to do is make 12 columns headed
Jan €“Dec and find all dates that are January from the grid and place them in
the column headed Jan, so if the date is in row 4 in the grid it would go in
row 4 in the column headed Jan and the same with the columns headed Feb. to
Dec.
I dont know if this is possible, it may be a fun challenge for some one.
Thank you, Barry.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 116
Default sorting cells

there should be only one Jan in each row , what i do is type a date into a
cell and it populates the grid in two monthly intervals so 12/1/09 would give
me 12/3/09-12/5/09 and so on, I will give your macro a go . do I stick it in
the VBA page ?

Thank you for your help. Kindest Regards,Barry.

"barry" wrote:

Hi, I wonder if any one can help, I have a grid of dates between €œY4 and
AD19€ (in a spread sheet) what I would like to do is make 12 columns headed
Jan €“Dec and find all dates that are January from the grid and place them in
the column headed Jan, so if the date is in row 4 in the grid it would go in
row 4 in the column headed Jan and the same with the columns headed Feb. to
Dec.
I dont know if this is possible, it may be a fun challenge for some one.
Thank you, Barry.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default sorting cells

If you want to place a date always in the same row then use this version:
Sub test2()
Dim datesrng As Range, dcell As Range
Set datesrng = Range("Y4:AD19")
For Each dcell In datesrng
destcol = Month(dcell.Value)
Cells(dcell.Row, destcol).Value = dcell.Value
Next dcell
End Sub

To install it:
Open VBA
right click your workbook name in the Project explorer window
InsertModule
Copy macro in the code window

Regards,
Stefi


€žbarry€ ezt Γ*rta:

there should be only one Jan in each row , what i do is type a date into a
cell and it populates the grid in two monthly intervals so 12/1/09 would give
me 12/3/09-12/5/09 and so on, I will give your macro a go . do I stick it in
the VBA page ?

Thank you for your help. Kindest Regards,Barry.

"barry" wrote:

Hi, I wonder if any one can help, I have a grid of dates between €œY4 and
AD19€ (in a spread sheet) what I would like to do is make 12 columns headed
Jan €“Dec and find all dates that are January from the grid and place them in
the column headed Jan, so if the date is in row 4 in the grid it would go in
row 4 in the column headed Jan and the same with the columns headed Feb. to
Dec.
I dont know if this is possible, it may be a fun challenge for some one.
Thank you, Barry.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 116
Default sorting cells

cheers

"barry" wrote:

Hi, I wonder if any one can help, I have a grid of dates between €œY4 and
AD19€ (in a spread sheet) what I would like to do is make 12 columns headed
Jan €“Dec and find all dates that are January from the grid and place them in
the column headed Jan, so if the date is in row 4 in the grid it would go in
row 4 in the column headed Jan and the same with the columns headed Feb. to
Dec.
I dont know if this is possible, it may be a fun challenge for some one.
Thank you, Barry.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default sorting cells

You are welcome! Thanks for the feedback!
Stefi

€žbarry€ ezt Γ*rta:

cheers

"barry" wrote:

Hi, I wonder if any one can help, I have a grid of dates between €œY4 and
AD19€ (in a spread sheet) what I would like to do is make 12 columns headed
Jan €“Dec and find all dates that are January from the grid and place them in
the column headed Jan, so if the date is in row 4 in the grid it would go in
row 4 in the column headed Jan and the same with the columns headed Feb. to
Dec.
I dont know if this is possible, it may be a fun challenge for some one.
Thank you, Barry.

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
SORTING CELLS LAURA Excel Worksheet Functions 2 July 24th 08 05:52 PM
Sorting Cells DamienO Excel Worksheet Functions 8 June 24th 08 08:40 AM
Sorting cells: a list behind the cells do not move with the cell Ross M Excel Discussion (Misc queries) 2 September 21st 06 12:14 PM
sorting cells according to all cells in column A Jootje Excel Worksheet Functions 2 August 16th 05 01:40 PM
Sorting a range of cells that get value from other cells Matt Caswell Excel Discussion (Misc queries) 3 July 13th 05 04:52 PM


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