+ Reply to Thread
Results 1 to 10 of 10

code is not giving the expected result

  1. #1
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,148

    code is not giving the expected result

    Hello Experts
    This code will extract the data of combined data sheet and display in the newly created sheet (HSN). The code has to extract data based on unique values of 3 columns. B J and R). When I filter the data of both the sheets the code has to match the amounts of each state code and each HSN code individually. But I am getting a mismatch in one of the HSN codes due to which the final result is incorrect. I need your expertise to check what is wrong in the code and help me to correct it. Thanks in advance.
    Attached Files Attached Files
    Last edited by RAJESH SHAH; 05-14-2023 at 04:56 AM. Reason: #Solved by veyselemre
    "There is nothing called problem, it's just absence of an idea to find*solution."
    ?I have not failed. I?ve just found 10,000 ways that won?t work.?
    ?Thomas Edison

  2. #2
    Registered User
    Join Date
    04-07-2019
    Location
    Turkey-Ankara-Çubuk
    MS-Off Ver
    Office 2010
    Posts
    71

    Re: code is not giving the expected result

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,148

    Re: code is not giving the expected result

    veyselemre. Can you please tell which part of the code did you edit.? Last 3 days I have been trying to figure out why the difference. I would like to know what was wrong in the code.

  4. #4
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,148

    Re: code is not giving the expected result

    Thank you very much veyselemre. It worked in the original data too. Phew!! Thank God the problem is solved.
    I compared the codes and found that you have replaced str with key which might have made the difference. Anyways thanks once again.

  5. #5
    Registered User
    Join Date
    04-07-2019
    Location
    Turkey-Ankara-Çubuk
    MS-Off Ver
    Office 2010
    Posts
    71

    Re: code is not giving the expected result

    Hello, I don't know english. I wrote it with a translator.
    1-Key is written instead of str variable. str is already a vb command. It does not give an error, but it is not recommended to use it.
    2-For the keys that are not found in the Dictionary, an index was created by saying x=x+1, but this index was not thrown into the dictionary.
    3-The index of the ones in the Dictionary was taken into the y variable and collected over the old values.
    Ekran Alıntısı.PNG

  6. #6
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,148

    Re: code is not giving the expected result

    What is the reason it is not recommended.? It gave the perfect results in all the state codes. Believe it or not, I was going mad to find the fault and finally after 3 days of head breaking I thought the code needs to be edited where and how I wasn't aware. But this helped me to complete my project successfully. You hit the last nail in the coffin.
    If it is not recommended will it give me any problems in future ...???

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,869

    Re: code is not giving the expected result

    It is bad practice to use Excel and/or VBA key words as variables, function names, or subroutine names. It can, and does, produce unexpected results, if not errors
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  8. #8
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,148

    Re: code is not giving the expected result

    Then is it possible to edit the present code and get the correct result without the key.... I have tried and posted multiple queries but I haven't got the correct expected result till now. If possible help me to edit the code without the key and get the expected result.
    Thanks for the update Trevor. Hope some expert will be able to edit the code without the key. Till then I will check different data to check if it is giving the result differently or incorrect.
    Even veyselemre warned in his post in the first line itself that it is not recommended to use key.
    Last edited by RAJESH SHAH; 05-14-2023 at 05:28 AM.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,869

    Re: code is not giving the expected result

    I should have said "Reserved words" rather than key words.

    For example, if I want to use a long variable to refer to a row number, I will use lRow rather than Row.

    So
    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code is not giving the expected result


    Quote Originally Posted by RAJESH SHAH View Post
    help me to correct it.
    Already solved in your previous thread where I gave you a faster way !

    TotalAP.jpg
    Last edited by Marc L; 05-14-2023 at 10:56 AM.

+ 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] Multiple Embedded IF & AND formula - not giving the expected result
    By ChrisMP in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-23-2019, 05:05 AM
  2. [SOLVED] VBA Code Autofilter criteria and row deletion not giving result
    By analystbank in forum Excel General
    Replies: 4
    Last Post: 02-09-2016, 02:29 AM
  3. [SOLVED] Index - Match formula not giving me an expected result
    By longbow007 in forum Excel General
    Replies: 5
    Last Post: 11-25-2015, 07:34 PM
  4. hyperlink help need code not returning expected result (partial)
    By AkaTrouble in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-04-2015, 11:21 AM
  5. [SOLVED] RgeNumba giving me 0 instead expected value
    By Sc0tt1e in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-04-2014, 02:53 PM
  6. [SOLVED] Future Date - TODAY() : not giving expected result
    By Psycho_uk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-08-2013, 04:37 AM
  7. OR Operator Line Not Giving Expected Result
    By Gos-C in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-22-2010, 06:14 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