#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Loop Code

Hello Gurus,

I am making a report of time in and time out with highlighting the
duraation.

The report work except that even if on the first report row is having
the same date and the specific time duration is empty it is going to
the nexrt row.

How i cud make to chack every time starting from second row(initial
RepCell) and if the interior color index is none and date is same
highligh the duration on the first report row itself?

Thanks

Sub ReportTest()

' data sorted on date and ArvTime
Sheets("TempReport").Select

Set CurCell = Worksheets("Data").Range("A2")
Set RepCell = Worksheets("TempReport").Range("A2")

Do While Not IsEmpty(CurCell)
Set X = CurCell.Offset(0, 3) 'ArvTime
Set Y = CurCell.Offset(0, 4) 'DepTime
Set W = CurCell.Offset(0, 5) 'Craft


STCol = Application.Match(X, Range("TimeS"), 0)
EDCol = Application.Match(Y, Range("TimeS"), 0)

CLR = Application.VLookup(CurCell, Range("AirDetails"), 3, False)

SDate = DateValue(TxtFrDate)
EDate = DateValue(TxtToDate)

Set NextCell = CurCell.Offset(1, 0)
Set NewRepCell = RepCell.Offset(1, 0)

'only data within date range
If CurCell.Offset(0, 2) = SDate And CurCell.Offset(0, 2) <= EDate
Then

RepCelll.FormulaR1C1 = CurCell.Offset(0, 2)
RepCell.Offset(0, STCol) = W
Range(RepCell.Offset(0, STCol), repcell.Offset(0, EDCol -
1)).Interior.ColorIndex = CLR
Range(repcell.Offset(0, STCol), repcell.Offset(0, EDCol -
1)).HorizontalAlignment = xlCenterAcrossSelection
Range(repcell.Offset(0, STCol), repcell.Offset(0, EDCol - 1)).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:= _
"Data!" & CurCell.Address, ScreenTip:=CurCell.Value

If CurCell.Offset(0, 2).Value = NextCell.Offset(0, 2).Value _
And NextCell.Offset(0, 3) CurCell.Offset(0, 4) Then
Set CurCell = NextCell
Else
Set CurCell = NextCell
Set repcell = NewRepCell
End If
Else
Set CurCell = NextCell
End If


Loop

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
Loop for VBA code? paulinoluciano Excel Worksheet Functions 5 December 28th 05 01:30 PM
How to Loop some code Phil Osman Excel Discussion (Misc queries) 2 August 19th 05 11:14 AM
How to get my code to loop Dominique Feteau[_2_] Excel Programming 5 December 17th 04 01:35 PM
Help with loop code... gaba Excel Programming 1 October 20th 04 01:37 PM
VBE code in a loop loloflores Excel Programming 0 April 30th 04 12:28 PM


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