Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default time selection

Hi,
I have 4 spreadsheets in my workbook called "master","1", "2", and "3". In
column K of the "master" sheet, the cell format is 'dd h:mm:ss'.
How do i write a macro that would go through that column....if it's less
than 5 hrs then move the row (from colum A to K) to sheet "1"...if it's
between 5hrs and 24 hrs then move that row to sheet "2" and if it's more than
24 hrs then move to sheet "3"...
the macro will keep on doing that until there is a blank line...

thanks.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default time selection

Hi,
actually before column K, there are 2 other columns with the format
yyyy/mm/dd hh:mm:ss...
column K is the result of one column minus the other column

"Sandy Mann" wrote:

With that format how are you managing to enter zero days without it decoming
text?

--
Regards,

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"Don Doan" wrote in message
...
Hi,
I have 4 spreadsheets in my workbook called "master","1", "2", and "3".
In
column K of the "master" sheet, the cell format is 'dd h:mm:ss'.
How do i write a macro that would go through that column....if it's less
than 5 hrs then move the row (from colum A to K) to sheet "1"...if it's
between 5hrs and 24 hrs then move that row to sheet "2" and if it's more
than
24 hrs then move to sheet "3"...
the macro will keep on doing that until there is a blank line...

thanks.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,345
Default time selection

This code assumes that the data starts in Row 3:

Sub MoveIt2()
Dim LastRow As Long
Dim cell As Range
Dim LastRow1 As Long
Dim LastRow2 As Long
Dim LastRow3 As Long
Dim cValue As Double

Sheets("Master").Activate

LastRow = Cells(Rows.Count, 11).End(xlUp).Row
LastRow1 = Sheets("1").Cells(Rows.Count, 11).End(xlUp).Row + 1
LastRow2 = Sheets("2").Cells(Rows.Count, 11).End(xlUp).Row + 1
LastRow3 = Sheets("3").Cells(Rows.Count, 11).End(xlUp).Row + 1

For Each cell In Range(Cells(3, 11), Cells(LastRow, 11))
If cell.Value < "" Then

cValue = cell.Value

Select Case cValue

Case Is < 5 / 24

Range(Cells(cell.Row, 1), Cells(cell.Row, 11)).Copy
Destination:= _
Sheets("1").Cells(LastRow1, 1)
LastRow1 = LastRow1 + 1
GoTo GetOut
Case Is <= 1
Range(Cells(cell.Row, 1), Cells(cell.Row, 11)).Copy
Destination:= _
Sheets("2").Cells(LastRow2, 1)
LastRow2 = LastRow2 + 1
GoTo GetOut
Case Else
Range(Cells(cell.Row, 1), Cells(cell.Row, 11)).Copy
Destination:= _
Sheets("3").Cells(LastRow3, 1)
LastRow3 = LastRow3 + 1
GetOut:
End Select
End If
Next cell

End Sub


If you want to remove the data as well then clear the constants after the
copying has been done.

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"Don Doan" wrote in message
...
Hi,
actually before column K, there are 2 other columns with the format
yyyy/mm/dd hh:mm:ss...
column K is the result of one column minus the other column

"Sandy Mann" wrote:

With that format how are you managing to enter zero days without it
decoming
text?

--
Regards,

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"Don Doan" wrote in message
...
Hi,
I have 4 spreadsheets in my workbook called "master","1", "2", and "3".
In
column K of the "master" sheet, the cell format is 'dd h:mm:ss'.
How do i write a macro that would go through that column....if it's
less
than 5 hrs then move the row (from colum A to K) to sheet "1"...if it's
between 5hrs and 24 hrs then move that row to sheet "2" and if it's
more
than
24 hrs then move to sheet "3"...
the macro will keep on doing that until there is a blank line...

thanks.







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
Moving selection right one column at a time: Is there a shortcut? RD[_2_] New Users to Excel 2 May 19th 09 05:39 PM
Selection.sort Run-time error '1004' [email protected] Excel Programming 2 October 19th 06 12:24 PM
Adding time selection to pop-up calendar RMF Excel Programming 1 March 6th 06 10:55 PM
Moving Range Selection Right One Column at a Time TexDad Excel Programming 2 December 17th 05 07:25 PM
Moving Selection and Time based run macro Iarla[_2_] Excel Programming 0 November 19th 04 12:52 PM


All times are GMT +1. The time now is 05:23 PM.

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

About Us

"It's about Microsoft Excel"