Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I'm working on a spreadsheet to calculate & track hours worked. When adding
only numbers into the form, the below macro works acceptably; however, I also need a way to track if a person was forced to work a day of overtime. I'm currently accomplishing this by having the text FR4 or FR5 entered into the cell instead of the hours worked. The referenced macro allows the addition of the day of the week hours to be added to a separate column and the result populated into another column for a yearly summation. Here is an attempt to explain the layout of my sheet and its use. Column L: Monday, input in rows below for hours / force tracking (FR4 / FR5) Column M: Tuesday, input in rows below for hours / force tracking (FR4 / FR5) Column N: Wednesday, input in rows below for hours / force tracking (FR4 / FR5) Column O: Thursday, input in rows below for hours / force tracking (FR4 / FR5) Column P: Friday, input in rows below for hours / force tracking (FR4 / FR5) Column Q: Saturday, input in rows below for hours / force tracking (FR4 / FR5) Column R: Sunday, input in rows below for hours / force tracking (FR4 / FR5) Column S: Week Total of Hours Worked -- Complex IF function to add any numeric values in columns L:R, and treat any input of FR4 as a value, and FR5 as a different value (let me know if the IF function is needed) Column T: Year Total Of Hours Worked -- Where a macro (credit to Don Guillett on this mssg board), takes the formula result from the day column I'm working on, adds it to the value in column T, and then places the result here (in column T) (this is the macro with the issue I'm describing - see below). I've created a button and linked the macro I'm referencing to it. As I said previously, the macro works fine if only numbers are used; however, when I add the FR4 or FR5, it tries to add the FR4 or FR5 to the number in column T, resulting in an error (specifically Run-time error '13' : Type mismatch). What I need is the same type of assignment of a numeric value to FR4 and FR5 that my IF function in column S accomplishes, then add it to the data in column T. (FR4 should equal 18, and FR5 should equal 24). I'm not very experienced with VBA and macros in Excel, but I feel like using variables would accomplish this? Any help would be greatly appreciated. FYI - I can't simply use the Week Total in Column S in this instance as the Year Total must be updated after each day's hours worked are assigned for individual because the Year Total determines that those with less accumulated hours for the year are first to be forced for overtime. This is the example of the macro I received from Don Guillett and modified for my use, it is currently set up to work on a single day (this example being my column for Monday (L)). Sub Move_To_Next_Day_Mon() For n = 8 To Cells(Rows.Count, "t").End(xlUp).Row Cells(l, "t") = Cells(l, "T") + Cells(l, "L") Next l End Sub Thanks, CVinje |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can a cell defined by a formula become an exportable numeric valu. | Excel Worksheet Functions | |||
Can I replace a ' at the beginning of a text cell using Replace | Excel Discussion (Misc queries) | |||
How do I replace text within a formula with a diff cell value? | Excel Worksheet Functions | |||
Replace Number with Text using Macro | Excel Discussion (Misc queries) | |||
I want to chage a whole rows text color based on single cell valu. | Excel Worksheet Functions |