+ Reply to Thread
Results 1 to 14 of 14

Simple Maths formula

  1. #1
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Simple Maths formula

    Hi guys,

    I have never done maths in VBA before, so would appreciate your help.

    It is a very simple equation:

    txtStockEOS1 = txtStockSOS1.value + txtStockReceive1.value - txtStockLost1.value - txtStockBroken1.value - txtStockWorn1.value

    I.e., 10 = 5+8-1-1-1

    Thank you!
    Last edited by onmyway; 02-05-2015 at 06:30 AM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Simple Maths formula

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Simple Maths formula

    hi shg

    Thanks for the response.

    How or where would I put the code? I would like the TextBox to calculate every time one of these fields change?

    Please Login or Register  to view this content.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Simple Maths formula

    In the Change event for each of textboxes on the right side of the = sign.

  5. #5
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Simple Maths formula

    thank you shg

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Simple Maths formula

    You're welcome.

  7. #7
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Simple Maths formula

    hi shg,

    I get a run-time error 13: type mismatch when I enter a value in one of my fields whilst testing. this is my code:

    Please Login or Register  to view this content.
    I am probably making some simple mistake...

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Simple Maths formula

    What the value in each textbox when the error occurs?

  9. #9
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Simple Maths formula

    Hi shg,

    Sorry for the belated response. Was over-committed this weekend.

    The error occurs no matter what value I enter. Numeric or alpha-numeric.

  10. #10
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Simple Maths formula

    Hi shg,

    Sorry for the belated response. Was over-committed this weekend.

    The error occurs no matter what value I enter. Numeric or alpha-numeric.

  11. #11
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Simple Maths formula

    Hi all,

    I still have not been able to solve this problem. I get a run-time error 13: type mismatch when I enter a value in one of my fields whilst testing. this is my code:

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Simple Maths formula

    FYI: When I calculate using a button, it works perfectly. it is the autocalculation via the _Change event that is causing the issue. it might have something to do with empty/blank fields?

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Simple Maths formula


  14. #14
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Simple Maths formula


+ 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. Key word formula and do some maths :)
    By seanobrathvilly in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-21-2014, 02:18 PM
  2. Understanding the maths in seasonal analysis formula
    By Kolacube in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-03-2013, 11:08 PM
  3. forecast using maths formula
    By okl in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-25-2013, 01:01 AM
  4. Using formula to answer a maths question?
    By simbalyon303 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-15-2013, 08:41 AM
  5. help: Maths and formula help
    By legion in forum Excel General
    Replies: 5
    Last Post: 03-29-2009, 07:43 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