+ Reply to Thread
Results 1 to 9 of 9

Specific VBA Calc.

  1. #1
    Registered User
    Join Date
    12-11-2019
    Location
    london
    MS-Off Ver
    2007
    Posts
    50

    Specific VBA Calc.

    Hi Forum,

    Maybe a simple question but I still need some help with a formula clarification:

    Could somebody help me with this:
    Please Login or Register  to view this content.
    what is wrong?

    Thanks in advance
    Last edited by alansidman; 07-09-2021 at 09:38 AM.

  2. #2
    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,448

    Re: Specific VBA Calc.

    Please Login or Register  to view this content.
    Judging by the ;2 at the end, I suspect you are missing a Round function somewhere.
    Last edited by alansidman; 07-09-2021 at 09:38 AM.
    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


  3. #3
    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,448

    Re: Specific VBA Calc.

    Oh, and I think VBA would expect a comma rather than a semi-colon.

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,223

    Re: Specific VBA Calc.

    TMS
    2, in my opinion, applies POWER.

    Kaizan
    You have used the sheet functions (POWER and SQRT) here as if they were VBA functions. But that's just one of the mistakes. Note that some VBA functions exclude the use of a sheet function in VBA-level calculations. This is the case with the VBA - Sqr function. You cannot use the sheet function SQRT in calculations. It is a bit different with the POWER function. You can use it in calculations, but you have to indicate that it is a sheet function (you'll see in a moment). Equivalent in VBA is sign (^), e.g.
    Please Login or Register  to view this content.
    However, the use of the SQRT sheet function will fail, e.g.
    Please Login or Register  to view this content.
    you must use the VBA function
    Please Login or Register  to view this content.
    With this knowledge, now try to write your calculations correctly.

    Artik
    Last edited by Artik; 07-09-2021 at 05:58 AM.

  5. #5
    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,448

    Re: Specific VBA Calc.

    @Artik: ah, thanks for that. POWER is not a function that I use so I couldn't see the relevance. Nor SQRT for that matter. Had worked out that it needed to be Application.WorksheetFunction.Power but was struggling with the bracketing.

    OK, this compiles:

    Please Login or Register  to view this content.

  6. #6
    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,448

    Re: Specific VBA Calc.

    And this compiles:

    Please Login or Register  to view this content.

  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,448

    Re: Specific VBA Calc.

    Yes, but he asked for help and I wanted to see it corrected … even then, it might not be the calculation Kaizan wants
    Last edited by TMS; 07-09-2021 at 07:59 AM. Reason: Fix typo

  8. #8
    Registered User
    Join Date
    12-11-2019
    Location
    london
    MS-Off Ver
    2007
    Posts
    50

    Re: Specific VBA Calc.

    Hi Forum,

    Thanks a lot for all the help! I am, however, having issues with the actual calculation result, which should appear in TextBox5 i have attached multiple examples on how I think this could be done.

    Thanks again!
    Attached Files Attached Files

  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,448

    Re: Specific VBA Calc.

    I'd create a Calculation Command Button and put your code in there.

    Please Login or Register  to view this content.
    But, as you can see, the results are zero.

    Results:
    Please Login or Register  to view this content.
    Unless my maths is off, this will give you a zero value:

    Please Login or Register  to view this content.
    You can't bracket it like this:
    Please Login or Register  to view this content.
    because the multiplication would give you a minus number and Sqr won't like that.

+ 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] Need VBA that adjusts calc. field references in formula based on specific previous column
    By Betsy Simpkins in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-25-2020, 02:16 AM
  2. Daily calc don't match monthly calc. why?
    By OldManSleepyhead in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-06-2019, 01:43 PM
  3. [SOLVED] Calc Numbers with decimals and having the Decimal be moved to new column to be Calc
    By TwistedFaith in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-24-2015, 12:01 AM
  4. Perform Calc On Specific Number Of Cells (Avoiding Blanks)
    By Phillycheese5 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-19-2013, 02:21 PM
  5. How do I set some wksht formulas to calc. manually and others to calc. automatically?
    By hoboking87 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-26-2013, 08:16 PM
  6. How do I create a macro(func) to calc. attendance with a set of specific conditions
    By Fredster31 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-16-2010, 12:02 PM
  7. [SOLVED] auto calc on, but have to edit (f2) cells to force re-calc..help!
    By Curt in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-13-2006, 02:10 PM

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