I’m entirely stuck and I don’t know how to progress, so any help will be greatly appreciated. What I want is fairly straightforward, but is fiddly and difficult to explain, so please bear with me. I’m currently achieving what I need using 14,600 insanely long array formulas which, obviously, isn’t ideal as I have to have calculations set to manual, which is screwing up other aspects of the sheet (when run, the calculations take about a minute).
I have workbook with 2 sheets on it called sheet1 & Calendar respectively.
Sheet1 contains a data dump from a database used to store staff holiday information. Columns A through H are used. The columns I’m interested in are A, B, C & D which are headed: Name, Date From, Date to and Type.
There are 4 codes for holiday/leave type: AL, FL, SL and Sick.
The Calendar uses columns A to NB. Column A contains a list of names down to Row 40, Row contains the numbers 1 or 2 (I’ll explain that in a minute), Row 2 contains the dates for the entire year (from column B to column NB).
Cells B3 to NB43 contain massive Sumproduct arrays. These arrays compare the Name in column A and the date in row 2 against columns A, B and C on sheet1 and enter the relevant information from column D.
The numbers in row 1 are slightly different, but are still part of the same array.
On sheet1 columns R to Y are used to display a 2 week grid for each staff member that displays what days they don’t work on. This information also comes from the database.
This would obviously be continued across the entire year for each member of staff.
The formula that currently produces this information is this:
Which, as I said, sits in 14,600 cells on the calendar (365 x 40 staff).
Is there any way that this can be achieved with a VBA macro rather than my ridiculously long arrays? If it could, it would mean that I would be able to have calculations set to automatic and other aspects of the workbook would work as they’re supposed to (I know I can set certain sheets to calculate manually, but other coding in the workbook (not mine) has rendered this not practical.
NB: I keep trying to add examples, but I can't get the formatting to hold.
I have workbook with 2 sheets on it called sheet1 & Calendar respectively.
Sheet1 contains a data dump from a database used to store staff holiday information. Columns A through H are used. The columns I’m interested in are A, B, C & D which are headed: Name, Date From, Date to and Type.
There are 4 codes for holiday/leave type: AL, FL, SL and Sick.
The Calendar uses columns A to NB. Column A contains a list of names down to Row 40, Row contains the numbers 1 or 2 (I’ll explain that in a minute), Row 2 contains the dates for the entire year (from column B to column NB).
Cells B3 to NB43 contain massive Sumproduct arrays. These arrays compare the Name in column A and the date in row 2 against columns A, B and C on sheet1 and enter the relevant information from column D.
The numbers in row 1 are slightly different, but are still part of the same array.
On sheet1 columns R to Y are used to display a 2 week grid for each staff member that displays what days they don’t work on. This information also comes from the database.
This would obviously be continued across the entire year for each member of staff.
The formula that currently produces this information is this:
Code:
=IF(COUNTIF(INDEX(Sheet1!$S:$Y,SMALL(IF(Sheet1!$R$2:$R$100=$A4,ROW(Sheet1!$R$2:$R$100)),B$1),0),B$2), "NW Day",IF(SUMPRODUCT(--(Sheet1!$A$2:$A$3520=$A4), --(Sheet1!$B$2:$B$3520<=B$3),--(Sheet1!$C$2:$C$3520>=B$3),--(Sheet1!$D$2:$D$3520="AL") , --(ISTEXT(Sheet1!$K$2:$K$3520))), "AL" ,IF(SUMPRODUCT(--(Sheet1!$A$2:$A$3520=$A4), --(Sheet1!$B$2:$B$3520<=B$3), --(Sheet1!$C$2:$C$3520>=B$3),--(Sheet1!$D$2:$D$3520="SL") , --(ISTEXT(Sheet1!$K$2:$K$3520))), "SL",IF(SUMPRODUCT(--(Sheet1!$A$2:$A$3520=$A4), --(Sheet1!$B$2:$B$3520<=B$3),--(Sheet1!$C$2:$C$3520>=B$3),--(Sheet1!$D$2:$D$3520="FL") , --(ISTEXT(Sheet1!$K$2:$K$3520))), "FL",IF(SUMPRODUCT(--(Sheet1!$A$2:$A$3520=$A4), --(Sheet1!$B$2:$B$3520<=B$3), --(Sheet1!$C$2:$C$3520>=B$3), --(Sheet1!$D$2:$D$3520="Sick")),"Sick","")))))
Which, as I said, sits in 14,600 cells on the calendar (365 x 40 staff).
Is there any way that this can be achieved with a VBA macro rather than my ridiculously long arrays? If it could, it would mean that I would be able to have calculations set to automatic and other aspects of the workbook would work as they’re supposed to (I know I can set certain sheets to calculate manually, but other coding in the workbook (not mine) has rendered this not practical.
NB: I keep trying to add examples, but I can't get the formatting to hold.