+ Reply to Thread
Results 1 to 4 of 4

Formulas used in spreadsheet to be written in code to go in Userform module

  1. #1
    Registered User
    Join Date
    11-24-2012
    Location
    Stratford-upon-Avon
    MS-Off Ver
    Excel 2007
    Posts
    89

    Formulas used in spreadsheet to be written in code to go in Userform module

    I have a userform that has text boxes that link to formulas in cells in spreadsheet to gain their value. It works ok, but I would like to start placing the calculation formulas into the userform textboxes themselves. I can see how to do simple sum and minus between textboxes but have no idea how to go about the formula below:

    The formula on spreadsheet that populates TextBox4 is:

    =IF(D83=-65,"0.00",+D65+SUM(D35:D37)+D83-SUM(D39:D48)-D64)

    The cells above are represented by these textboxes on the userform:

    D83 = TextBox97
    D65 = TextBox55
    D35 = TextBox28
    D36 = TextBox29
    D37 = TextBox30
    D39 = TextBox31
    D40 = TextBox32
    D41 = TextBox33
    D42 = TextBox34
    D43 = TextBox35
    D44 = TextBox36
    D45 = TextBox37
    D46 = TextBox38
    D47 = TextBox39
    D48 = TextBox40
    D64 = TextBox54

    Any help would be most wecome

    Stratfordoaks

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Formulas used in spreadsheet to be written in code to go in Userform module

    Hi,

    It's not clear, at least to me, what you mean by "placing the calculation formulas into the userform textboxes themselves". Are you wanting to see a string of text that describes the formula in the text box or a resultant value.

    Please upload your workbook and tell us what is your overall aim. We usually like to approach these things from first principles since there is often a simpler and more efficient way than the one presented.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    09-24-2013
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: Formulas used in spreadsheet to be written in code to go in Userform module

    You can't write a formula, that will be operate on textboxes. The best way is write UDF, for example:
    Please Login or Register  to view this content.
    The second way is write UDF, that will be operate on spreadsheet, where you can use spreadsheet's functions:
    Please Login or Register  to view this content.
    Of course there is much more solutions.
    Last edited by hudibyk; 11-25-2013 at 06:47 AM.

  4. #4
    Registered User
    Join Date
    11-24-2012
    Location
    Stratford-upon-Avon
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Formulas used in spreadsheet to be written in code to go in Userform module

    Thank you for your reply Richard. Yes I agree if you see what I have there may be a simpler solution. I have attached the workbook which with the form is used for cashing up purposes at our club. At the moment Userorm1 is used to populate the cells in sheet "Daily". This sheet has varios formulas in cells which sum up totals but also provide the "checks" to see if the till has balanced. A macro is run to post the data in "Daily" to the other sheets in the Workbook.


    Eventually my aim is to do away with sheet "Daily" and the Userform1 to populate the relevant worksheets when the macro runs. When the form opens go to the last page and enter "Admin" with the password "1". Worksheet "Daily" can be unprotected with password "1"

    Kind regards

    Nigel
    Stratfordoaks
    Attached Files Attached Files

+ 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] Why do I get an error when running the code for an UserForm from a standard module?
    By kjy1989 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-24-2013, 01:50 AM
  2. userform event handling within a standard code module?
    By jerseyguy1996 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2010, 01:01 PM
  3. Create a macro (module?) that activates in my userform code?
    By Bafa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-17-2008, 09:15 PM
  4. Module vs. UserForm - where should I be storing my code?
    By js999 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2007, 02:26 PM
  5. Code in userform/worksheet vs. in Module
    By davegb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-19-2006, 11:20 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