+ Reply to Thread
Results 1 to 14 of 14

vba from to check my math

  1. #1
    Registered User
    Join Date
    01-13-2014
    Location
    oakdale,ca
    MS-Off Ver
    Excel 2010
    Posts
    48

    vba from to check my math

    I am trying to create a form in VBA to check my math by using text boxes with specific values and to show the total in a verification box.
    The "Day" box would be $10 the "Boat" box would be $7 ect. and I have some check boxes that would change the values if checked.
    After all of that happens I would like each total to show up on a list. I have attached a sample. click "ADD Iron Ranger " to see the form.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    01-13-2014
    Location
    oakdale,ca
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: vba from to check my math

    is my Question too vague?

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,219

    Re: vba from to check my math

    Hi jlamela,

    It looks like you have added TEXT boxes to your userform instead of CheckBoxes, so maybe your question is vague.
    UserForms and VBA programming are MUCH MORE involved than using a spreadsheet without needing them.

    Instead of creating a Userform of your own, Excel has a Form Tool that is already built into the product. Read about it at:
    http://www.addintools.com/documents/...data-form.html
    and
    http://spreadsheets.about.com/od/dat..._data_form.htm
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    01-13-2014
    Location
    oakdale,ca
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: vba from to check my math

    the text boxes allow for multiple items. I tried the form that you suggested but it didn't do quite what i was looking for. I would like it to total the information before it gets sent to the spreadsheet so that i know the information is entered correctly.

  5. #5
    Registered User
    Join Date
    01-13-2014
    Location
    oakdale,ca
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: vba from to check my math

    it seems to me that it should be simple, the number in the text box times the amount of the text box with the total placed in the verification box. then do the same for the next text box and add it to the verification box. but the code alludes me.

  6. #6
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: vba from to check my math

    is my Question too vague?
    No, but there was no data for examples on the sheet. While it may all seem obvious to you, I can't determine what you're adding up or whether my results would be correct. Could you update the sheet to include data?
    Last edited by Tinbendr; 02-02-2015 at 11:33 AM.
    David
    (*) Reputation points appreciated.

  7. #7
    Registered User
    Join Date
    01-13-2014
    Location
    oakdale,ca
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: vba from to check my math

    Sorry I didn't think data would be relevant with this problem being only on the form for verification. Hopefully this helps there are still other issues I haven't worked out yet. one problem at a time for me. I also have some things in VBA that I have tried and failed with.
    Attached Files Attached Files

  8. #8
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: vba from to check my math

    I think the best way is to iterate all the controls, adding them up as you go. This way, if you have to make a correction, the code will update it for you. You could call this sub after each entry, but I think I would just add a "update" button to calculate the totals.

    Copy to standard module, or inside a commandbutton.

    Please Login or Register  to view this content.

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,219

    Re: vba from to check my math

    Hi jlamela,

    I've added a Userform2 to your work and some code behind it to do what I think you want. The code looks like:
    Please Login or Register  to view this content.
    Hopefully this will give you enough of an example to figure your problem out.

    When you create TEXT boxes they are TEXT not VALUES and VBA doesn't do conversion of them like Excel does. I think this is half of your problem.

    In the Immediate window type "Userform2.Show" and press enter to see how my example works.
    Attached Files Attached Files
    Last edited by MarvinP; 02-02-2015 at 12:20 PM.

  10. #10
    Registered User
    Join Date
    01-13-2014
    Location
    oakdale,ca
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: vba from to check my math

    Both of your examples seem to work grate. I will have to play with the code to figure out which works better for this application.. thank you
    MarvinP is there a box that uses values that I could use? or do I have to use "CInt" on any text box that I want numbers in. (For future projects)

  11. #11
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: vba from to check my math

    or do I have to use "CInt" on any text box
    I'll jump in to say that it's hit or miss when performing math on textboxes. That's why you have to check it against know totals to make sure it's calculating correctly. But you can always force the textbox to the correct variable type as Marvin has illustrated, to be absolutely sure. When the cursor is over CInt, press F1 for a list of all conversion functions.

  12. #12
    Registered User
    Join Date
    01-13-2014
    Location
    oakdale,ca
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: vba from to check my math

    OK seem to have that working. Grate job.. Next issue, in my addto lines of code. How do I tell it that if the cell is "empty" to do nothing. I have the problem lines marked with " ' " so I don't get a type mismatch error each time I run.

  13. #13
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: vba from to check my math

    I have the problem lines marked with " ' "
    Did you mean to attach another version?

  14. #14
    Registered User
    Join Date
    01-13-2014
    Location
    oakdale,ca
    MS-Off Ver
    Excel 2010
    Posts
    48

    Re: vba from to check my math

    sorry i have been gone for awhile . tinbender it is in the original copy in vba

+ 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] tax math
    By allgeef in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-05-2013, 07:00 PM
  2. I thought this would be easy (check for text, check error, do math)
    By bruinsrme in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-14-2013, 01:18 AM
  3. Automatically check one or more check boxes when a parent check box is manually checked
    By Steverizer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-28-2013, 01:56 PM
  4. Check a math statement when leaving a worksheet
    By pingwin77 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-04-2010, 05:25 PM
  5. Replies: 3
    Last Post: 02-16-2006, 07:00 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