+ Reply to Thread
Results 1 to 12 of 12

Vlookup and returning previous months data

  1. #1
    Registered User
    Join Date
    05-08-2015
    Location
    Middle of Nowhere
    MS-Off Ver
    2010
    Posts
    38

    Vlookup and returning previous months data

    Hello,

    I am trying to see if the a # is in the current month and the previous month, if so return the value in column "S".

    Data

    1234 12-31-2014 18% <----- return this data
    1233 12-31-2014 19%
    1234 01-31-2015 20% ___ <----- Here

    Do I have to use an if statement or can it all be done with a vlookup formula.

    Current statement that I am using is =vlookup(g100,g2:g99,12,false) I am trying to prevent going back and locating the previous month (there are over 100k lines)

    I am also using =vlookup(g100,g200:g300,12,false) to see if the same # shows up in the next month as well.

    All help is greatly appreciated.
    Attached Files Attached Files
    Last edited by sevanseriesta; 08-25-2015 at 02:06 PM.

  2. #2
    Forum Contributor
    Join Date
    08-07-2015
    Location
    AB, Canada
    MS-Off Ver
    Excel 2013 x64
    Posts
    132

    Re: Vlookup and returning previous months data

    The following solution uses ARRAY formulas which must be entered by pressing CTRL + SHIFT + ENTER instead of just ENTER.

    Assuming you have values from rows 2 through 32 with your codes in column A, dates in column B, current % in column C, and the formula to return prior month's % in column D, this formula can be entered in cell D2 by pressing CTRL + SHIFT + ENTER and then copied down.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-08-2015
    Location
    Middle of Nowhere
    MS-Off Ver
    2010
    Posts
    38

    Re: Vlookup and returning previous months data

    The Array was entered but returned a blank:

    Using CTRL + SHIFT + ENTER

    =IFERROR(INDEX($R:$R,MATCH(G782&DATE(YEAR(R4),MONTH(R4),0),$G:$G&$R:$R,0)),"")

  4. #4
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Vlookup and returning previous months data

    Post a workbook with some sample data and expected results, it makes it much easier to help you.
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  5. #5
    Forum Contributor
    Join Date
    08-07-2015
    Location
    AB, Canada
    MS-Off Ver
    Excel 2013 x64
    Posts
    132

    Re: Vlookup and returning previous months data

    Make sure your code cell is lined up with the corresponding date cell. G782 is not lined up with R4.

    Also, I only see two columns in your formula. The places you see column C in my previous post should be the column with your current period % values.

  6. #6
    Forum Contributor
    Join Date
    08-07-2015
    Location
    AB, Canada
    MS-Off Ver
    Excel 2013 x64
    Posts
    132

    Re: Vlookup and returning previous months data

    Another solution, this time one that doesn't use an array formula. It requires your dates are sorted oldest to newest.

    Again, in my formula the columns contain data starting in row 2:
    A: codes
    B: dates
    C: current period % value
    D: prior period % value (desired result)
    Please Login or Register  to view this content.
    *This one does not have to be entered with CTRL + SHIFT + ENTER

    example1.jpg
    Last edited by ThirdFret; 08-25-2015 at 02:01 PM. Reason: attached example solution

  7. #7
    Registered User
    Join Date
    05-08-2015
    Location
    Middle of Nowhere
    MS-Off Ver
    2010
    Posts
    38

    Re: Vlookup and returning previous months data

    I have added my worksheet to the original post.

  8. #8
    Forum Contributor
    Join Date
    08-07-2015
    Location
    AB, Canada
    MS-Off Ver
    Excel 2013 x64
    Posts
    132

    Re: Vlookup and returning previous months data

    Quote Originally Posted by sevanseriesta View Post
    I have added my worksheet to the original post.
    Great, that will make it easier to help! I assumed you only had "month ending" dates in your date column, so my first two solutions might give you wonky answers.

    Here's another ARRAY FORMULA that will return the "Balace (CAD)" for a given code from its prior month. This one is a little slow, so I would suggest trimming the ranges to your needs if you have a larger dataset.

    Again, this must be entered with CTRL + SHIFT + ENTER
    Please Login or Register  to view this content.
    See example worksheet:
    test1.xlsx
    Last edited by ThirdFret; 08-25-2015 at 02:24 PM. Reason: added worksheet

  9. #9
    Forum Contributor
    Join Date
    08-07-2015
    Location
    AB, Canada
    MS-Off Ver
    Excel 2013 x64
    Posts
    132

    Re: Vlookup and returning previous months data

    Quote Originally Posted by sevanseriesta
    So I should have explained better. The date that you are referencing does not matter in the whole equation. All I need to know on the test sheet is if the code ever appeared in the previous month (column L) I added the vlookup formula I was using in the original post to help understand kind of what I was manually doing.

    So in your test sheet what I need is:

    If "Column A" appears in January (column L), did it also appear in the previous month. If it did I was just having it return "Column L", but I am ok with it returning column L also, I hope that clears it up.
    The following formula, entered as an ARRAY formula in cell M2 (enter by pressing CTRL + SHIFT + ENTER), will return the previous month if the listed code exists in the previous month. It will return blank if there is no exact match.
    Please Login or Register  to view this content.
    *See attached:
    test1.xlsx
    Last edited by ThirdFret; 08-25-2015 at 03:30 PM. Reason: Added file

  10. #10
    Forum Contributor
    Join Date
    08-07-2015
    Location
    AB, Canada
    MS-Off Ver
    Excel 2013 x64
    Posts
    132

    Re: Vlookup and returning previous months data

    I may have overcomplicated the problem. Here is a formula that works better than the above example and is not an array formula.

    Please Login or Register  to view this content.
    See attached *
    test1.xlsx
    Last edited by ThirdFret; 08-25-2015 at 03:20 PM. Reason: added file

  11. #11
    Registered User
    Join Date
    05-08-2015
    Location
    Middle of Nowhere
    MS-Off Ver
    2010
    Posts
    38

    Re: Vlookup and returning previous months data

    Thanks, Third. Both of those fix my issue.

  12. #12
    Forum Contributor
    Join Date
    08-07-2015
    Location
    AB, Canada
    MS-Off Ver
    Excel 2013 x64
    Posts
    132

    Re: Vlookup and returning previous months data

    Quote Originally Posted by sevanseriesta

    And if I wanted to search to see if my code is in the following month would I change the ">" to "<" to see if it also appeared in the next month?
    Not quite. You'd have to change the date that the COUNTIF is looking for. The following code would return the following month instead of prior.
    Please Login or Register  to view this content.
    Glad to help, Sevanseriesta. I've posted the PM discussion you and I had in case others have similar problems. Cheers!

+ 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] Add data for previous six months in a number of columns.
    By zany in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-24-2013, 09:27 AM
  2. [SOLVED] Find last previous non blank value and summarise previous 6 months
    By Lady_Shaz in forum Excel General
    Replies: 7
    Last Post: 12-11-2012, 06:20 AM
  3. Previous 6 months data
    By highflyer2509 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-21-2012, 06:05 PM
  4. Formula to show current and previous months data
    By dandavis1 in forum Excel General
    Replies: 4
    Last Post: 07-06-2012, 02:02 PM
  5. how to get last day of previous 2 months...
    By jgomez in forum Excel General
    Replies: 3
    Last Post: 06-13-2011, 01:36 PM
  6. Getting data from previous months
    By gloom52 in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 09-21-2009, 06:18 AM
  7. delete previous months data
    By karloss in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-16-2009, 07:14 AM
  8. [SOLVED] how to keep previous months' data
    By braadi in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-09-2006, 11:55 AM

Tags for this Thread

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