Error By Create Schedule Programmatically - schedule

I want to create a (on/off)schedule in variable via excel and it will used in a resourcePool. I have whote the code in a function like this:
```
1. v_Workshift = new Schedule<Boolean>();
2. v_Workshift.setOwner(this);
3. v_Workshift.setCalendarType(true);
4. v_Workshift.setFirstDayOfWeek(MONDAY);
5. v_Workshift.setTimeUnits(DAY.toMilliseconds());
6. v_Workshift.setPeriod(1);
7. v_Workshift.setGlueIntervals(true);
8.
9. v_Workshift.addInterval(1, b1, b2, b3, 1, b4, b5, b6, true);
10. v_Workshift.addInterval(1, c1, c2, c3, 1, c4, c5, c6, false);
11. v_Workshift.addInterval(1, d1, d2, d3, 1, d4, d5, d6, false);
12.
13. v_Workshift.initialize();
```
The prameter b,c,d are the start time and end time from excel.
And the error is:
Parameter capacityScheduleOnOff is not specified (null/empty)
Can anyone tell me how to solve this problem?
Thank you in advance

This error is actually coming from the ResourcePool object. It seems that you've selected an option capacity defined by on/off schedule but you didn't actually set the reference to the v_Workshift object into the appropriate field in the ResourcePool that this schedule is supposed to control.

Related

how to copy values in a diagonal down a range using vba

I have a range of data in one column like so:
and I'm trying to copy each value after the one in "A1" and move it one column over and up one row, for example (A2 copied to B1, A3 copied to B2, A4 copied to B3 etc.) like so:
Is there a few lines of code that can do this successfully?
In B1:
=IF(ISBLANK(OFFSET($A1,COLUMN()-1,0)),"",OFFSET($A1,COLUMN()-1,0))
fill down and across
Alternate:
=IF(ROW(B1)>COUNTA($A:$A)-COLUMN(A1),"",INDEX($A:$A,COLUMN(B1)+ROW(B1)-1))

Excel set cell list value to cell above based on condition

In Excel column D is of a list type. Cell D3 is correctly populated according to the list. When A4 is not null D4 must be equal to D3. This works fine when A4 is not null, however when A4 is blank I get a validation error. The idea is when I do not have a value in A4 nothing should happen in D4, i.e. D4 should also remain blank.
I have tried
=if(A4<>"",D3,"")

Excel: A function to replicate built-in change in relative references when copying formulas

I need a function that will do what Excel does automatically when you dreag a formula: change the referneces automatically.
For example:
In A1 I have "= A2 + A3"
If i copy this to say C3 it will have: "= C4 + C5"
I need to WRITE a formula in C3 that will produce this.
Any ideas? VBA solution is also welcome
CLARIFICATION:
In need this to be as general as possible.
Meaning A1 can contain ANY formula of any type, containing references to other cells.
for example: "= A2 + A3" or "= VLOOKUP(A2, $C$1:$E$7, 2, True)"
In need to move have this formula, whatever it is, copied to another cell (say C3), w/o the built in copy/paste, and have the references (that aren't set with $) change relatively.
I thought there might be a function to write in the destination file to do this.
I have tried writing an Eval function, and i managed to copy the formula from A1 and have it evaluated in C3, but the references would not change
This question lacks a bit of clarity, but I think this might be what you're after:
=SUM(OFFSET(C3,1,0,2))
This will sum the two cells directly below the given cell (in this case, cell C3). That is, it offsets C3 by 1 row, 0 columns, and grabs a height of 2 cells and then passes the result to the SUM function.
This VBA code would do what you are looking by setting the formula in the active cell:
ActiveCell.FormulaR1C1 = "=R[+1]C+R[+2]C"
You can use the Indirect() function using relative reference style.
For example, if you were in A1 and wanted to sum B1 & C1, it would look as follows:
A1: =INDIRECT("RC[1]",0)+INDIRECT("RC[2]",0)
That will change as you move the cell around to always sum the 2 cells to the left of the cell.
For your specific example (A1 = A2 + A3 || C3 = C4 + C5), it would be as follows:
=INDIRECT("R[1]C",0)+INDIRECT("R[2]C",0)
Hope that does the trick!!

Excel VBA - Import or copy columns to another workbook in a different order

I am trying to import an excel file having headers as A1, B1, C1, D1, A2, B2, C2, D2, A3, B3, ...D4 and each of the headers having data for 150 rows. I have to import this data set to another workbook but in the order:
A1, A2, A3, A4, B1, B2, B3, B4,....D4
You can do it by doing a custom sort.
Home Tab >> Sort & Filter >> Custom Sort >> Options
Then change the sort from "Sort top to bottom" to "Sort left to right". Then its just a matter of selecting which row and how you want to sort it.

How to find a Particular value in particular range

Here is a example of the sheets, in which I am trying to create a macro with vba.
In the first sheet, there is a value for NAME in D3, which is 25, it can change but number only.
In second sheet, there is table. Where b1,b2, b3, b4 till b13, are name(variable) values from 1 to 13(As in sheet d3, different value). In A1 to a13, there is serial no. from 1 to 13.
In third sheet, there is table.
Where b1,b2, b3, b4 till b13, are name(variale) values from 14 to 26(As in sheet d3, different value). In A1 to a13, there is serial no. from 1 to 13.
So, I want that the macro should check for sheet 1 d3 value in all worksheet, if found it will check for the serial no. against it, put the no. in E6 filed.
Sorry of I've misunderstood your question but it sounds like a vlookup might do the trick rather than the need to write VBA and use the Find method.
If you combine the second and third sheet, so that Column A contains the possible values for NAME in D3, and the Serial Number in Column B, like this.
NAME | Serial
-----|-------
1 | qwerty
2 | bob
... | ...
You can then use a LOOKUP query as follows in E6.
=VLOOKUP($D$6,Sheet2!A:B,2,FALSE)
Hope this helps.