+ Reply to Thread
Results 1 to 3 of 3

Executing Part Of Macro Only On Cells Meeting A Condition

  1. #1
    Registered User
    Join Date
    03-28-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    37

    Executing Part Of Macro Only On Cells Meeting A Condition

    I'm working on a spreadsheet designed to track total overtime hours worked in a year; on the spreadsheeet is a column to keep track of each day's total OT, the week's total OT, as well as a column to track the year's total. There is a formula in the week total, but the year total is calculated via a macro (day of the week total, added to the existing year total, result updated, so, each day has it's own button and macro). We have a shift that works a different week than the shift that needs to track overtime, but still must be included in the list. Therefore, I created a column to place the shift designator so there can be recognizable diffrerentiation. With quite a bit of help from this board, and others, I've created (or been kindly given) the following macro (this is just a part of it) to total the day's overtime and existing year overtime and input the result into the cell. I now need to have this executed only when the condition I specify (say, in cell D1) is met (that would be the shift, for example the text M1 or SST). Please note, the week totals are only for user reference - they do not come into play for calculations of year totals. The below macro actually takes the totals from a day of the week and adds it to the existing year total, placing the result in the year total column.

    Please Login or Register  to view this content.
    I've attached a screen capture to illustrate my question. You'll notice two additional columns for "Force" overtime. These will have to have the same macro as above executed on them to calculate and track a running total for the year versus the week's total (appropriate changes to cell designations already made & working). I should be able to modify any code to work with both, I'm just having a problem getting the macro to work properly on either based on my condition. Your help, is again and always, appreciated.

    Using Excel 2003
    Windows XP

    CVinje
    Attached Images Attached Images
    Last edited by CVinje; 07-13-2009 at 02:13 AM. Reason: Solved by myself..........

  2. #2
    Registered User
    Join Date
    03-28-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    37

    Re: Executing Part Of Macro Only On Cells Meeting A Condition

    I assume I've received no replies because I've not clearly expressed the problems and requested resolution. I've worked on this and have been able to get to this point:
    Please Login or Register  to view this content.
    This actually counts the number of entries on the list that corresponds with the condition in cell D1, then continues to add the values that are numbers in column R starting from row 8 and working down to the last cell with entries in column W. It's close to what I want - but it does not skip peforming calculations on rows with different entries in column W, the action is still performed on the values in those row when they should be skipped (I've explained more of the problem and desired resolution on the spreadsheet provided for your review).

    I've attached the full workbook for your review; please ignore the mess that the code and everything else is in the workbook - I'm a novice and I know it's a mess and probably improper. Unless you're willing to correct any of the messy code - just ignore it - I don't want to waste your time asking for help fixing the whole workbook, just this one part and I think I'll be very close to then working on learning more about VBA and correcting my methods.

    **Note:after solving this problem with help from a different forum, removed the referenced attached spreadsheet.

    Thanks again,

    CVinje
    Last edited by CVinje; 07-13-2009 at 02:26 AM. Reason: Corrected attached workbook to exclude reference to data links

  3. #3
    Registered User
    Join Date
    03-28-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    37

    Re: Executing Part Of Macro Only On Cells Meeting A Condition

    I was able to receive a reply to solve my problem from another forum - solution posted here just in case somebody else has a similar question...
    Please Login or Register  to view this content.
    CVinje

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1