+ Reply to Thread
Results 1 to 2 of 2

Extract year

  1. #1
    Registered User
    Join Date
    11-10-2005
    Posts
    7

    Exclamation Extract year

    Hello everyone, can anyone help me with a problem I'm having. I'm trying to figure out how to extract just the last to digits of the year "06" so I can put that value in a cell.

    What I'm doing is setting up a receipt worksheet & when I run the macro I want it to check the current year & save just the "06" portion to the variable strYear so then I can append it to the contents of the cell K3 which contains the number of the receipt.

    Example: Cell K3 value is 105, after I run the macro it will get the "06" portion of the year and the value of cell K3 and in cell K4 display 06-105 as the Receipt number for the invoice.

    Hope I explained this ok.

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    11-10-2005
    Posts
    7
    Never mind replying I figured it out finally.
    This is the code I used to get the last 2 numbers of the year.

    strYear = Format(Now, "yy") 'Gives me the 06 from the year
    strReceiptNo = ActiveCell.Value 'Gets the current receipt number
    ActiveCell.Formula = strReceiptNo + 1 'Adds 1 to the value of the receipt
    strValue = strYear & "-" & strReceiptNo "Stores the value 06-100 in the variable
    ActiveCell.Formula = strValue 'Enters the Receipt number in the cell

    Probaly did it the hard way but it works.

+ 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