Thank you for the attachment. It really helps to see your layout.
idris.cheikh wrote:Sheet1 reuses a modified version of your formula that deals with blank cells too).
VLOOKUP can match the empty cells and supply 0 as their value, so you don't need to use IF and ISBLANK in your formula. See Q26/A26 in the VLOOKUP tutorial. I was surprised it didn't already cover that situation.
idris.cheikh wrote:I am starting to wonder if I shouldn't have stuck with the code
For someone with a background which focuses on
imperative programming, I can appreciate that it is natural to want to use macros for your calculations. The problem with that in an OpenOffice environment is that one then needs to use the Application Programming Interface, which is very difficult to understand. It raises hundreds of questions about "How do I access cell attribute X?", "How to I change cell attribute Y?", "How do I get control when Z happens?", "How can my macro create a formula which references the cell above?" etc. It can be difficult for a beginner to determine how to access the service one wants or which interface can perform a desired operation. Things like "How can I tell if a cell is merged?" or even "How do I determine the active cell?" can be surprisingly complicated. It will take at least a week of your time to
begin to understand the API. While you may be able to find examples on the forum for some tasks, that can be challenging, and "copy and paste" programming without really understanding the API is unlikely to be suitable except for very simple tasks.
idris.cheikh wrote:I do not know much about spreadsheets.
The
Ten Concepts tutorial is a good place to start. But in this case I will tell you that your data layout is going to make using formulas difficult. You are using a "cross table" which presents information in a 2-dimensional layout, which is nice for display but not well-suited for performing calculations. It is much better to organize in "normal form" with data in columns, where each cell in a column contains the same type of information, as I did in the
UseAuxillaryColumns sheet which uses very simple formulas for its calculation. For example, column A might contain an agent name, column B a date, C a service, D and E the start and end times, F the duration, etc. We have numerous posts on the forum where people propose a cross table but can't determine how to calculate something and a volunteer shows how to reorganize into normal form and then the calculation is simple. In your situation, once the calculations are complete you can create another sheet which presents the information in a cross table for display. These display sheets are often very simple to create using the Pivot Table feature where no additional formulas are needed.
idris.cheikh wrote:* I need to account for a 10% increase in the number of hours depending on whether a given service took place on a Sunday or at night.
* I should also count holiday hours for certain agents and not others, and in varying quantities, depending on their contract (e.g. 168h/month, or 160h, or 150h; info in the cell next to the agent's name).
* Finally, I need to check whether the distribution of services is in compliance with the law according to a set of rules I still need to study.
These seem as if they should be possible, though someone who says "I do not know much about spreadsheets" may need help. They key is to use auxiliary columns to hold sub-calculations (like the duration above) so that the formulas do not become too involved. Counting holiday hours will probably involve a table which provides those dates.
idris.cheikh wrote:Taking the above into account, would you still recommend against writing macros or not?
If it were me, I would use macros as an absolute last resort. Other volunteers may have different opinions. My preference is to use the standard features of Calc, formulas, pivot tables, filters, sorting, etc. A hybrid approach with Calc (which is
functional programming) and imperative programming is to use the latter, say Perl or Python, to create a CSV file after all of the calculations have been completed, then use
[Example] Loading CSV into preformatted spreadsheets to display the CSV data as a spreadsheet, perhaps creating a pivot table as the final step.
If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the subject field. Select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).