+ Reply to Thread
Results 1 to 9 of 9

Values through match function

  1. #1
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    261

    Values through match function

    Hi All

    User inputs a date and we will add one day to it as a result but if the result date is in particular range(lets say from a1:10) it should add one day from that day in the range. I am using a match function to check if the resultant dates are in a range.


    I am using dateserial to add dates . If say user input 12/09/2013 we will get 13/09/2013. If the same
    13/9/2013 is in that holiday list (in that range i meant) it should add 1 day to 13/09/2013 so that result wil be 14/09/2013

    The following is the code.

    Please Login or Register  to view this content.
    many thanx
    Last edited by grkchakri; 12-03-2013 at 01:30 AM.
    Never confuse a single defeat to the final defeat.

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

    Re: Values through match function

    This web page may help:
    A Better WORKDAY Function
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

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

    Re: Values through match function

    This prompts for a date entry, and uses the Workday2 function from the link above to add one day.
    Assumes no weekend and the holidays listed on Sheet1 A1:A10

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 12-03-2013 at 02:35 AM.

  4. #4
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    261

    Re: Values through match function

    hanx alpha. But that looks like complicated and i am going through it , However in the meanwhile i just wanted to check if was able to ask my question and get across the point that i am looking for,

    * I want to add one day to the one user inputs

    * Even if it is a sunday /saturday it is ok with me

    * If the range(holiday list ) has dates for example
    06-12-2013
    12-12-2013

    * Basically whenever the result is in the holiday list it will should show the subsequent day

    Will the workday2 function will remove all the days in the list at one time
    or whenever the result is in the holiday list?

    many thanx
    Last edited by grkchakri; 12-03-2013 at 03:53 PM.

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

    Re: Values through match function

    Quote Originally Posted by grkchakri View Post
    hanx alpha. But that looks like complicated and i am going through it , However in the meanwhile i just wanted to check if was able to ask my question and get across the point that i am looking for,

    * I want to add one day to the one user inputs

    * Even if it is a sunday /saturday it is ok with me

    * If the range(holiday list ) has dates for example
    06-12-2013
    12-12-2013

    * Basically whenever the result is in the holiday list it will should show the subsequent day

    Will the workday2 function will remove all the days in the list at one time
    or whenever the result is in the holiday list?

    many thanx
    I understood the question and that's what I had attempted to answer.

    What if you had two or more consecutive holidays dates in your holiday list? You would need to do more than just test for one match of the holidays.

    The solution I suggested may be slight overkill, but it should do what you want. All you have to do is copy the Workday2 function from the link and the code I provided. That's it.

    If you don't have to consider weekends, here's a more simple version. It doesn't use the Workday2 function.

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 12-03-2013 at 05:53 PM.

  6. #6
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    261

    Re: Values through match function

    Sorry to open this post again. Since the match function turns out be a little unmatched to my knowledge. I want to learn a bit more rather than
    being ignorant

    In the above code i just want to understand why isnumeric was used at the do while stage. My point is we are trying match with a date in range which is/should already be in date format.

    I have tried to write one more example where it simply try to match with the date value which the user entered in the inputbox and tries to match
    the value in a range. But to my surpise it throws a TYPE MIS MATCH ERROR: (RUNTIME ERROR 13
    The code is as below

    Please Login or Register  to view this content.
    Last edited by grkchakri; 12-11-2013 at 01:25 AM.

  7. #7
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    261

    Re: Values through match function

    SAME AS ABOVE, Previously i posted it with the marker solved. Just edited that option to open the question
    in the forum.

    many thanx

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

    Re: Values through match function

    ISNUMBER returns TRUE if the Match function returns a number (match found) or it returns FALSE if the Match function errors (no match found).

    Your code is testing if z equals the result from the match function.
    If z = Application.WorksheetFunction.Match(CLng(x), CRAN, 0) Then

    They will never match because z doesn't equal anything. It's empty. Your code doesn't have a syntax problem. It has a logic problem.
    Last edited by AlphaFrog; 12-12-2013 at 02:02 PM.

  9. #9
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    261

    Re: Values through match function

    Thank you alpha for that insight i was able to modify the code as below and got the match function working for me

    Please Login or Register  to view this content.

+ 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. function to match values in 3 columns
    By brichigo in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-11-2012, 12:04 PM
  2. using match function for duplicate values
    By enocht in forum Excel General
    Replies: 9
    Last Post: 07-12-2010, 11:11 PM
  3. Index and Match function returning same values
    By Climaxgp in forum Excel General
    Replies: 4
    Last Post: 12-15-2009, 05:59 AM
  4. [SOLVED] Using Match function with duplicate values in an array
    By bj in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 12:05 PM
  5. Using Match function with duplicate values in an array
    By Richard in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 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