View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.programming
Max Bialystock Max Bialystock is offline
external usenet poster
 
Posts: 19
Default complex looping problem

Sheet 1 is a page for the user to work out a roster for a fortnight.



The dates are in B2:O2.



The names of the staff are in A4:A25.



If a cell is empty or contains a zero the worker has that day off.



If a cell contains an "a" they work a normal shift.



Sheets 4 to 25 are the attendance/payroll input sheets.



Sheet 4 corresponds with the name in sheet1 A4.



HR insist on a specific format for these sheets and this is where much of
the difficulty lies. Information to be included is:

the start time sheet4 C7

the finish time sheet 4 D7

the meal break sheet4 E7

the type of leave sheet 4 F7

the amount of leave (h:mm) sheet 4 G7

the total hours worked (h:mm) sheet 4 H7.



So an "a" in sheet 1 B4 has to translate as (09:00, 17:30, 0:45, 0, ) on
sheet 4.

H7 contains formula, which calculates the hours worked.



To further complicate things the fortnight is divided into two weeks.



The first week of the fortnight occupies the range C7:H7, C13:H13.

The second week C17:H17, C23:H23.


















"Bob Phillips" wrote in message
...
Hi Max,


"Max Bialystock" wrote in message
...
Hi Bob,
Sorry to trouble you again.

Run like as amended below it works perfectly.

If the array is expanded to include 5 6 7 8 whatever happens to sheet 8
happens to each sheet.

What I need to happen is that the data in row 4 of sheet 1 winds up in

sheet
4 and the data in row 5 of sheet 1 in sheet 5 and so on.

If you've had enough of this now, I'll understand.


Get out of here! We'll crack it.

The biggest difficulty I have is envisaging eaxctly what you arev trying

to
do, as I obviously don't have the data or the requirements as you know

them.

Having said that, the Weeks procedure looks wrong. Try this variation and
let me know.

Sub Weeks(x As Long, sh As Worksheet)
Dim r As Long 'this points to the worksheet row
Dim c As Long 'this points to the array column, not the worksheet column
Dim SheetValues As Variant

With Worksheets(1)
SheetValues = .Range(.Cells(x, 2), .Cells(x, 8)).Resize(1,

7).Value
WeekNum 7, 1, 13, SheetValues, sh
SheetValues = .Range(.Cells(x, 9), .Cells(x, 15)).Resize(1,

7).Value
WeekNum 17, 1, 23, SheetValues, sh
End With

End Sub