Consulting

Results 1 to 9 of 9

Thread: VBA not doing Mathmitical calculation when its ran

  1. #1
    VBAX Regular
    Joined
    Mar 2013
    Posts
    45
    Location

    VBA not doing Mathmitical calculation when its ran

    Hello all,

    Thank you for your time in reading this.
    I have the following code that runs and brings data from sheets to a Data Sheet.

    Option Explicit 
    Sub Quote() 
        Dim i As Integer 
        Dim ws As Worksheet 
        Dim sh As Worksheet 
        Dim lr As Integer 
        Dim ar As Variant 
        Set sh = Sheet14 
        For Each ws In ThisWorkbook.Worksheets 
            If Left(ws.Name, 5) = "Quote" Then 
                ws.Range("D6:D62").AutoFilter 1, ">0" 
                lr = ws.Range("C" & Rows.Count).End(xlUp).Row 
                If lr >= 7 Then 
                    Sheet14.Range("A65536").End(xlUp)(2).Value = ws.Name 
                    ws.Range("A7:G62").Copy Sheet14.Range("C65536").End(xlUp)(2) 
                    sh.Range(sh.Cells(sh.Cells(Rows.Count, 1).End(xlUp).Row, 1), _ 
                    sh.Cells(sh.Cells(Rows.Count, 3).End(xlUp).Row, 1)).Value = ws.Name 
                End If 
                ws.AutoFilterMode = False 
            End If 
        Next ws 
    End Sub
    Heres the problem:
    When the Above code is run it isnt doing the calculation from E7:F62. For example E7 has =ROUND(L7/(1-N7),2) and E8 has =E7*D7. When the code is run its putting the Formula there on the DataQuote Sheet, and not the results.

    Also Id like to make one Modification:
    say I would Like to Exempt a Sheet. On Sheets Quote 1, Quote 2, Quote 3, Quote 4, and quote 5 I have a Checkbox that is Linked to R6 on each sheet so that if its Checked r6 goes true. If R6 on any of those sheets says True, Exempt that sheet or sheets from the DataQuote Sheet which is Sheet14..


    Any thoughts is greatly appreciated.

    Thank you!

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Could you be creating a circular error? If you still have issues, can you post your workbook?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    Mar 2013
    Posts
    45
    Location

    Heres the Workbook In question

    if needed the password is net1444 There is a macro that will Unprotect it all
    Attached Files Attached Files

  4. #4
    VBAX Regular
    Joined
    Mar 2013
    Posts
    45
    Location

    Here is whats wrong template

    See Attached The tabs are RED
    Attached Files Attached Files

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I can't replicate your problem. Make sure that Calculation is not set to Manual (maybe left over by some other code?)
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    VBAX Regular
    Joined
    Mar 2013
    Posts
    45
    Location

    Ive attached a Picture

    See attachment
    Attached Images Attached Images

  7. #7
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    When the code is run its putting the Formula there on the DataQuote Sheet, and not the results.
    Would it work better if you did a Copy / PasteSpecial values in order to get the values into the output?

    Little more complicated because of the filters, etc. but that's the easiest way to get rid of formulas (AFAIK)

    Paul

  8. #8
    VBAX Regular
    Joined
    Mar 2013
    Posts
    45
    Location
    What ever is easier. I just dont know how to impliment it

  9. #9
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •