LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Macro looping problem.

I am a co-op student at Delphi and I have been asked to come up with a
macro that will looks at one column of times and then determine which
shift it is and print the shift letter in another column.

The code I am using is this:

Sub fillInShiftColumna()
Dim timeA1 As Date, timeA2 As Date, timeB1 As Date
Dim timeB2 As Date, timeC1 As Date, timeC2 As Date
timeB1 = TimeValue("7:00:00 AM")
timeB2 = TimeValue("14:59:59 PM")
timeA1 = TimeValue("23:00:00 PM")
timeA2 = TimeValue("6:59:59 AM")
timeC1 = TimeValue("15:00:00 PM")
timeC2 = TimeValue("22:59:59 PM")
Dim cell As Range
For Each cell In Range("A1:A100")
If cell.Value = timeB1 And cell.Value <= timeB2 Then
cell.Offset(0, 1).Value = "B"
ElseIf cell.Value = timeC1 And cell.Value <= timeC2 Then
cell.Offset(0, 1).Value = "C"
ElseIf cell.Value = timeA1 And cell.Value <= timeA2 Then
cell.Offset(0, 1).Value = "A"
End If
Next
End Sub

The macro works but only loops to row 16 and I can't figure out why.
Any help would be greatly appreciated.

 
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
Excel application.quit in macro problem TimkenSteve New Users to Excel 3 August 17th 06 06:36 PM
Problem with Before_Save Macro Jay Excel Discussion (Misc queries) 5 May 18th 06 06:47 PM
deleting a macro resulted in a problem militant Excel Discussion (Misc queries) 0 April 26th 05 05:21 AM
Circular Problem needs Macro NICK Excel Discussion (Misc queries) 2 February 1st 05 09:09 AM
Problem executing a macro from different workbook where it is Sergio Calleja Excel Discussion (Misc queries) 1 January 17th 05 12:38 PM


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