+ Reply to Thread
Results 1 to 10 of 10

revising a line of code

  1. #1
    Registered User
    Join Date
    03-08-2013
    Location
    usa
    MS-Off Ver
    Excel 2003
    Posts
    39

    revising a line of code

    Hi All. I have this line of code that looks for Sunday as the last day in the workweek and then add total hours. If Sunday Repeats go to nexx line and perform the function

    If UCase(Range("c" & x)) = "SUNDAY" And UCase(Range("c" & x + 1)) <> "SUNDAY" Then 'check if end of week has occurred, skip if there are two successive Sundays
    Rows(x + 1).Insert 'insert row
    x = x + 1
    Range("k" & x) = tot_hrs 'put total hrs worked for the week
    tot_hrs = 0 'initalize tot_hrs to 0
    End If

    the problem with this is that sometimes people last day of work could have been a Saturday and a Sunday entry would not be in the spreadsheet i.E.
    Monday
    Tuesday
    Wednesday
    Thursday
    Saturday
    Friday
    Thursday
    Saturday
    Wednesday
    Thursday

    What i would like to do is revise the line so as to, when Sunday is not there, then add the lines perform the same function on the last workday prior to Sunday.

    Thanks

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: revising a line of code

    could you attach a file with the above code?

  3. #3
    Registered User
    Join Date
    03-08-2013
    Location
    usa
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: revising a line of code

    here is the file thanks
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    03-08-2013
    Location
    usa
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: revising a line of code

    on the above example the workweek ended on WED,

  5. #5
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: revising a line of code

    this way is better
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    03-08-2013
    Location
    usa
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: revising a line of code

    Thanks for the code, I input 4 in the box for day of week Wednesday nothing happened. thanks

  7. #7
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: revising a line of code

    i changed 2 to 1 in weekday function
    but this isn't enought
    you haven't got all weekdays in a week
    so your code is becoming more complicated

  8. #8
    Registered User
    Join Date
    03-08-2013
    Location
    usa
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: revising a line of code

    ok, Thanks for trying

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: revising a line of code

    Maybe ...

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Registered User
    Join Date
    03-08-2013
    Location
    usa
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: revising a line of code

    thanks guy, I just got another code to fill in the missing dates, and got it working. thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Need help on revising this if formula
    By thisring in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-29-2013, 07:40 PM
  2. Need help revising formulas
    By RicksMom in forum Excel General
    Replies: 2
    Last Post: 03-21-2011, 03:10 PM
  3. Macro for Export/Import - need help revising a code
    By emptycucumber in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2009, 01:27 PM
  4. Combobox Revising with every access
    By sjumbo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-15-2006, 01:30 PM
  5. [SOLVED] need help revising
    By day in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-01-2006, 10:30 AM

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