+ Reply to Thread
Results 1 to 5 of 5

Macro for vacation accrual needed

  1. #1
    Registered User
    Join Date
    03-29-2012
    Location
    Germany
    MS-Off Ver
    Office 365
    Posts
    42

    Macro for vacation accrual needed

    I am working on a vacation accrual sheet & need some help please:
    Every pay period, the monthly accrual is logged in columns labeled “A”. The accrual is done by placing an “x” in row 2 of each period (eg. O3, Q3, S3, etc). This will populate the entire column with a number that corresponds with the length of service period defined in L, M, N. So, if the person has been in the company for 1-4 years = 1, 5-9 years = 2 and for 10+ years = 3. When someone moves from one category (L, M, N) into the next, it sets all previous accrual fields to that number. For example: moving from the 1-4 yrs category (which would show a “1” in O, Q, S, etc. into the next one of 5-9 yrs (which should be a “2” in the accrual colums) then all previous “1”s end up as a 2.
    I need a solution that copies the current accrual column onto itself with its values only. I created a Macro for that but the problem with this is that I have to create about 100 of those, one for each “A” column.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    03-29-2012
    Location
    Germany
    MS-Off Ver
    Office 365
    Posts
    42

    Re: Macro for vacation accrual needed

    OK, after some research I found a VBA code I think I can use if there is one thing that can be added. The code I found is this?

    Sub NoCopyAndPaste()
    Sheet1.Range("A1:A10").Value = Sheet1.Range("A1:A10").Value
    End Sub

    Is there a way to manually input the range (........:.....) before I run the macro, using something like a userform or so??? I don't want to overwrite the formulas in the future, just in the past, so I want to enter the range to copy & paste manually?!

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro for vacation accrual needed

    You could calculate the years of service for each "A" column based on the dates in row 3.

    Put this in O6 and copy down and across.
    =IF(AND(O$2="x",$D6>0,$D6<O$3),LOOKUP(DATEDIF($D6,O$3,"y"),{0,5,10},{1,2,3}),"")

  4. #4
    Registered User
    Join Date
    03-29-2012
    Location
    Germany
    MS-Off Ver
    Office 365
    Posts
    42

    Re: Macro for vacation accrual needed

    Hi AlphaFrog,
    sorry for not replying earlier, but I didn't have a chance to try out your solution. And it works perfectly fine. Thanks so much!!! I really appreciate your help!!!

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro for vacation accrual needed

    You're welcome and thanks for the feedback.

+ 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