+ Reply to Thread
Results 1 to 12 of 12

mACRO NOT CALCULATING DIFFERENCE BETWEEN SHEETS CORRECTLY

  1. #1
    Registered User
    Join Date
    04-23-2022
    Location
    london
    MS-Off Ver
    office365
    Posts
    90

    mACRO NOT CALCULATING DIFFERENCE BETWEEN SHEETS CORRECTLY

    I have a macro that I inhereted in a workbook and its not working properly.

    What its meant to do is compare figures between sheet called "TAB" and "WFD" and what ever the difference is it shows the data on the sheet called Sheet 3.

    Take for instance the workbook enclosed. the value in TAB is -358.50 and the value in WFD is -379.10 of which is 20.60.

    When I run the macro it comes up with a diff of 28.80. This is just a minor diff but when I run it with loads of data (lets say 6000 entries) The difference is massive,

    Why is this, I know very little on macros so I have a cheek asking if you could amend the workbook that would be great.



    THanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,205

    Re: mACRO NOT CALCULATING DIFFERENCE BETWEEN SHEETS CORRECTLY

    Data in Sheet3 does not appear to relate to data in TAB or WFD.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

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

    Exclamation Re: mACRO NOT CALCULATING DIFFERENCE BETWEEN SHEETS CORRECTLY


    And difficult to compare dates as Excel dates and dates as texts ! …

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

    Cool Re: mACRO NOT CALCULATING DIFFERENCE BETWEEN SHEETS CORRECTLY


    Anyway according to the attachment to just calculate the difference between both sheets an Excel basics VBA demonstration :

    PHP Code: 
    Sub Demo1()
        
    MsgBox "Difference  :  " CCur(Application.Sum(Sheet1.UsedRange.Columns(4)) - Application.Sum(Sheet2.UsedRange.Columns(4)))
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 11-21-2022 at 09:54 AM.

  5. #5
    Registered User
    Join Date
    04-23-2022
    Location
    london
    MS-Off Ver
    office365
    Posts
    90

    Re: mACRO NOT CALCULATING DIFFERENCE BETWEEN SHEETS CORRECTLY

    Thanks Marc. What you done is correct to show what the difference is between the 2 sheets but im trying to find out what entries make up that difference.

    It maybe in tab called Watford and not in tab called tableau and VV.

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

    Arrow Re: mACRO NOT CALCULATING DIFFERENCE BETWEEN SHEETS CORRECTLY


    If dates comparison is necessary so it works only with smart worksheets which is very not the case with your attachment …

  7. #7
    Registered User
    Join Date
    04-23-2022
    Location
    london
    MS-Off Ver
    office365
    Posts
    90

    Re: mACRO NOT CALCULATING DIFFERENCE BETWEEN SHEETS CORRECTLY

    All of columns A-D I need to compare

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

    Question Re: mACRO NOT CALCULATING DIFFERENCE BETWEEN SHEETS CORRECTLY


    So back to post #3 : why so many dates as texts in sheet WFD ?‼

    As the code was not made for such dumb case …

  9. #9
    Registered User
    Join Date
    04-23-2022
    Location
    london
    MS-Off Ver
    office365
    Posts
    90

    Re: mACRO NOT CALCULATING DIFFERENCE BETWEEN SHEETS CORRECTLY

    When I download the file it downloads as a .CSV file and then I save as an excel workbook am I doing it wrong there?

    I have now done a format on the cells

    Select the first value in column D that show the pound sign
    Right-click->Copy
    Select the whole column
    Right-click and under Paste Options choose Formatting which is the 5th symbol in

    The issue I have now is tht in the watford tab the first 2 entries are nit changing and have tried to format cells but still no diff. This is how much im out by.

    Any Ideas.
    Attached Files Attached Files
    Last edited by gareth7412; 11-21-2022 at 12:26 PM.

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

    Arrow Re: mACRO NOT CALCULATING DIFFERENCE BETWEEN SHEETS CORRECTLY


    Just a text file bad import settings !

    Activate the Macro Recorder, import manually the text file and well answer to the Import Wizard
    in order once imported the dates must be directly aligned to the right (numbers) rather than to the left (texts) …

    Anyway according to your attachment Sheet3 result must only contain 20 missing rows on the WFD side.
    Last edited by Marc L; 11-21-2022 at 12:29 PM. Reason: typo ...

  11. #11
    Registered User
    Join Date
    04-23-2022
    Location
    london
    MS-Off Ver
    office365
    Posts
    90

    Re: mACRO NOT CALCULATING DIFFERENCE BETWEEN SHEETS CORRECTLY

    just so im 100% correct i do the following..

    Download the CSV file
    click on transform data??
    click on close and load??
    save as a XLS file??

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

    Arrow Re: mACRO NOT CALCULATING DIFFERENCE BETWEEN SHEETS CORRECTLY


    If you well answer to the Import Wizard the dates are directly imported as Excel dates without any 'transform data' neither close etc …

    Anyway according to your actual source data worksheets an attachment with the exact expected result should help so far
    in order to replace your actual overcomplicated code with an Excel basics shorter - half size ! - VBA procedure
    working even with such badly imported dates !
    Last edited by Marc L; 11-21-2022 at 02:11 PM. Reason: typo ...

+ 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. Calculating (4Threads) - my Excel Sheet is not calculating correctly
    By cupoftee in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 06-23-2021, 06:55 AM
  2. Replies: 3
    Last Post: 08-12-2017, 01:48 AM
  3. Macro that can compare sheets between 2 workbooks, highlight the difference
    By jeffboy29 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-19-2013, 11:31 AM
  4. [SOLVED] Calculating difference between 2 dates in excel 2003 - formula not working correctly
    By cf7046 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-03-2013, 10:18 PM
  5. Macro not calculating correctly
    By theebookzoo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-24-2011, 11:30 AM
  6. Macro is not looping correctly through all sheets
    By dagindi in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-25-2011, 01:12 PM
  7. [SOLVED] Macro not calculating correctly
    By Ozgur Pars in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-17-2006, 10:55 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