+ Reply to Thread
Results 1 to 7 of 7

Macro shows incorrect result

  1. #1
    Registered User
    Join Date
    11-10-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    4

    Question Macro shows incorrect result

    Good Afternoon everyone,

    I'm trying to figure this code to fix the following issue. So this Excel macro has 3 sheets (Old, New, and Results), it works by adding an old report to the "Old sheet" and adding
    a new report to "New Sheet". When I run the macro it shows me New orders, Revised Orders, or cancelled on the "Results sheet" and is color coded however I came across an error. If you look at order # 90946 on the second row it shows that is a New order. It's supposed to be revised or "Version" (Yellow) because the version changed from 1 to 2 based on the Old sheet and New Sheet. If you look at order # 99047 on the Results tab you know that it's correct because it went from version 8 to 9. I don't know why order 90946 shows that is New, it's supposed to be a version change from 1 to 2.

    I've attached the excel macro and VBA code is below. Please and thank you.


    VBA Code:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by fsalas2006; 01-24-2014 at 08:00 PM. Reason: I had to add proper formatting for code

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,705

    Re: Report Macro Help

    Welcome to the forum. Unfortunately, you have not observed two important rules that govern this forum.

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    ------------------------------


    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Macro shows incorrect result

    Hi fsalas2006,

    I suspect that it is because by the time you get to the point where your comment says "Clean up Added Information" the value in cell K2 shows as #REF

    I wasn't watching closely enough as I stepped through the code to see exactly where it went wrong, will have to try again and pay more attention.

    I did notice however that when you 'Copy all sheets into Results' that you are selecting an extra blank row, not sure if you mean to do that or not?? (your f & s counters are already +1 when you leave your do loops

    Cheers

    Jmac1947

    1. Please consider clicking on the * Add Reputation if you think this post has helped you
    2. Mark your thread as SOLVED when question is resolved

  4. #4
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Report Macro Help

    ps... welcome to the forums, please take the time to do as @alansidman suggests, read the forum rules to make it easier for the volunteers to help you

  5. #5
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Macro shows incorrect result

    Hi fsalas2006,

    It looks like the offending code causing the #REF is this section.

    Please Login or Register  to view this content.
    I am not at all sure why you are doing this in the manner that you are, ie delete a heading row and insert another immediately after it. Maybe you should simply copy & paste a range rather than delete & insert but I guess you know your logic and what you are looking to achieve

    I havent gone any further with testing the final outcome
    Last edited by jmac1947; 01-24-2014 at 09:53 PM. Reason: forgot to subscribe to thread

  6. #6
    Registered User
    Join Date
    11-10-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Macro shows incorrect result

    Thanks you for the input jmac1947,

    I found out what makes order # 90946 show up as "New" on the results. The reason is coming up as new is because the "Old Sheet" is not looking at the second row. I did a little test where i went into the Old sheet and duplicated the second row right below it. I ran the macro again and it showed me the correct result as "Version". Any thoughts on how i can fix that under VBA?

  7. #7
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Macro shows incorrect result

    Hi fsalas2006,

    I am now a bit confused, I saved your original spreadsheet from the first post again, ran the macro and only ended up with one line in the results tab showing H_90946 as order # and 1 as VERSION

    Is that what I am expecting or has the data somehow managed to get corrupted??

    Jmac1947

+ 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. Macro to take a report
    By vinayjan in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-03-2013, 07:20 AM
  2. Macro to Automate Report by Case Number and Product Type (Macro Recorder Fail)
    By maxutility in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2012, 10:39 PM
  3. Change source data Macro (macro) in report template
    By andygeb in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-14-2010, 11:14 PM
  4. Report macro
    By nightcrawler-jay in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-14-2010, 01:37 PM
  5. A report macro
    By Jocke in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 04-20-2005, 09:06 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