LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default Add If formula in macro (replace cell text value with numeric valu

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can a cell defined by a formula become an exportable numeric valu. kate Excel Worksheet Functions 4 September 27th 07 07:01 PM
Can I replace a ' at the beginning of a text cell using Replace Hilde Excel Discussion (Misc queries) 4 September 10th 07 06:22 PM
How do I replace text within a formula with a diff cell value? Eric_G Excel Worksheet Functions 1 July 18th 07 03:30 PM
Replace Number with Text using Macro Carter68 Excel Discussion (Misc queries) 3 April 19th 05 08:57 PM
I want to chage a whole rows text color based on single cell valu. thediamondfam Excel Worksheet Functions 2 January 12th 05 12:15 AM


All times are GMT +1. The time now is 10:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"