+ Reply to Thread
Results 1 to 12 of 12

VBA to lookup for a specific value and give result

  1. #1
    Forum Contributor
    Join Date
    02-13-2014
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    140

    VBA to lookup for a specific value and give result

    I Have a workbook with 2 sheets " Acct. Details" and "Manual Checking"
    In sheet "Manual Checking" have a column F (UTR NO.2) which contains digits.

    Check the same digits in Sheet "Acct. Details" in column C (Particulars).
    If string in C of Sheet "Acct. Details" contains the Digits of Column F of Sheet "Manual Checking" then in column "I" in "Manual Checking" should show SR. no. (Column D) from Acct Details.
    If the digits are not exists the result should be "No Sr."

    For example please refer sheet "Result Needed". Required result marked in grey colour
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to lookup for a specific value and give result

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-13-2014
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    140

    Re: VBA to lookup for a specific value and give result

    Hi, Its working, but it not working on duplicate entries

    There are some number from sheet "Manual Checking" in a column F (UTR NO.2) which contains digits. has multiple records in Sheet "Acct. Details" in column C (Particulars).

    If there is more than one entry the SR number should be more than one and should be seprated by "^". Please refer attachment sheet "result needed", example marked in Orange colour

    For an example:

    The number "299463012" in Column F of sheet "Manual Checking" contains in column C of sheet "ACCT. DETAILS" for 2 times hence the SR number is "5385^4888"

    The number "26260857" in Column F of sheet "Manual Checking" contains in column C of sheet "ACCT. DETAILS" for 3 times hence the SR number is "1766^4211^9089"

    can you please change the code accordingly?

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to lookup for a specific value and give result

    Try:

    Please Login or Register  to view this content.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: VBA to lookup for a specific value and give result

    winmaxservices

    The results are bit different...
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: VBA to lookup for a specific value and give result

    I think this one does what you need.
    It's a modified macro using John's macro
    The macro to run: Modifiedwinmaxservicesz
    Attached Files Attached Files
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  7. #7
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA to lookup for a specific value and give result

    do i mis something or is there a reasen ?

    row 52 Nr 15299483 in your sheet needed result = 6037

    but rows 38,43 en 47 have also Nr 15299483 in column C


    Kind regards
    Leo

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: VBA to lookup for a specific value and give result

    There are 41 values in column F that occurs more than once, but that's the OP's problem
    8 occur 4 times
    9 occur 3 times
    24 occur 2 times
    Last edited by Keebellah; 11-09-2015 at 04:34 PM. Reason: xtra infor

  9. #9
    Forum Contributor
    Join Date
    02-13-2014
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    140

    Re: VBA to lookup for a specific value and give result

    Hi, Your code works perfectly.
    I am new to VBA. Can you please explain the code that how it works? means functions of each line by line. Just for my knowledge.

    Thanks

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: VBA to lookup for a specific value and give result

    Here's the code with comments:

    Please Login or Register  to view this content.
    It's really all just a step by stpe do this if that else something else

  11. #11
    Forum Contributor
    Join Date
    02-13-2014
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    140

    Re: VBA to lookup for a specific value and give result

    Hi, I checked the code. But it is not working for few cells.

    Please find attached workbook.
    in Sheet Manual Checking Cell "I7" should show 30303, but shows only 303. Because SRL No.in sheet "ACCT.DETAILS is 30303
    in Sheet Manual Checking Cell "I8" should show 28282, but shows only 282. Because SRL No.in sheet "ACCT.DETAILS is 28282

    Can you please check and revert with changes in code
    Attached Files Attached Files

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: VBA to lookup for a specific value and give result

    Why are you not using my code?
    It works if you use the code where you asked me to add comments and explain it.
    The attached file does not contain my vba code so it doesn't work!

+ 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. Need Formula to lookup for specific text in a string and give desired output.
    By winmaxservices1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-18-2014, 03:45 PM
  2. Lookup and place result in specific cell
    By kjones600 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-09-2014, 12:46 AM
  3. [SOLVED] Lookup multiple criteria in table and give row + culmn as result
    By bidsinga in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-02-2014, 03:40 PM
  4. need a lookup formula to return a specific result...
    By tsiguy96 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-15-2013, 08:40 AM
  5. [SOLVED] i have multiple lookup in my excel, its give result "0" i want blank outpu.
    By vengatvj in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-25-2013, 02:05 PM
  6. Replies: 1
    Last Post: 09-17-2012, 09:35 AM
  7. Lookup/Find Sheet then give value of specific cell within sheet
    By DoriBeE in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2011, 08:42 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