+ Reply to Thread
Results 1 to 27 of 27

Converting a successful Excel Spreadsheet to a VBA based user form.

  1. #1
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Converting a successful Excel Spreadsheet to a VBA based user form.

    Hi,

    I've recently constructed a spreadsheet which makes a simple calculation when a component is selected, It works perfectly
    but I've been asked to supply another department. However, to do that its apparent that something in VBA will
    be alot more suitable and stable.

    So, I've compiled a combo box with a list of items which determines my variance in the calculation.
    The Combo box has (currently) 3 variables in the box:
    C05093 = which equals 50
    C05094 = which equals 53
    C05095 = which equals 55

    Therefore, the calculation is:

    Team Size - C05095 - offset = 1235mm
    1300mm - 50mm - 10mm = 1235mm

    The variable part is the pull down menu of C05095.

    Any advice?

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    It's not entirely clear exactly what advice you are asking for!

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    OK , I'll prep one now

  4. #4
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    The file is on way and been modified for confidentiality. If you enter a team size and change the action it will change the width which determine the recommended outcome, Ignore answer and MBC columns.

    Thanks
    Attached Files Attached Files
    Last edited by bralew; 09-06-2016 at 06:17 AM.

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    Sorry, I'm still not clear on what you are actually asking for....

  6. #6
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    I'm trying to determine the VBA code to emulate what the spreadsheet does i.e. - enter team figure, pull down the action menu which will give you a width and that will provide the user with a recommended reading, which the the figure that is important.

  7. #7
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    Try this:
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    should i paste in the module or user form?

  9. #9
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    In UserForm. But I think it would be better if you can declare a global array() for the action values.

  10. #10
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    I would keep the master data in a worksheet, as it already is, then use something like:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

    It will be much easier to manage modifications to your master data on a worksheet, than embedded in your form code. You can always set the data sheet to be completely hidden, if you want to protect it from your users.

  11. #11
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    It works great, there's just one other amendment and its ready to go. Rather than display the 55 in the min box, would it be possible to take the following and put the outcome in the min box:
    Say, 1300 - BRCKT016 (55) - 10 = 1235, whereby the 1235 is displayed in the Min Box??

  12. #12
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    Sorry scrap that, it's easier to add another text box and use that as the outcome.

  13. #13
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    So my VBA code now has to take the contents of Team Size minus the min box minus 10 and display the outcome in an extra box called position.

  14. #14
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    Quote Originally Posted by bralew View Post
    So my VBA code now has to take the contents of Team Size minus the min box minus 10 and display the outcome in an extra box called position.
    Did you try my code, in post #10 ?

  15. #15
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    I would suggest loading two columns (Action and Width) from the sheet into the combobox control. You can hide one by making its ColumnWidth 0 but then refer to that value directly for the selected item rather than needing to look it up each time.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  16. #16
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    Sorry Olly, now seeing it. I've decided to refrain from putting any data in the Excel Spreadsheet and use VBA methods exclusively. I was able to design OK with Excel but my VBA is currently limited. I'm going to try and keep every thing in the VBA domain rather than have different data locations.

  17. #17
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    Quote Originally Posted by bralew View Post
    Sorry Olly, now seeing it. I've decided to refrain from putting any data in the Excel Spreadsheet and use VBA methods exclusively. I was able to design OK with Excel but my VBA is currently limited. I'm going to try and keep every thing in the VBA domain rather than have different data locations.
    Why? There aren't different domains there is only Excel, all you're doing with VBA is automating it, why would you want to make things more difficult and less flexible?

  18. #18
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    It's an unusual way of doing it - the worksheet is a PERFECT place for storing a 2 dimensional array of values, such as your bracket list, with corresponding widths.

    If you insist, though, then I'd store your master data in a couple of constants. So, in a standard module, enter the following:
    Please Login or Register  to view this content.

    Then in your userform module, enter:
    Please Login or Register  to view this content.
    See attachment for a worked example.
    Attached Files Attached Files

  19. #19
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    Hi,

    I,ve tried this code but to no avail. Basically, I want text box 3 to display the results of the sum of text box1 and text box2. Here's the code

    Please Login or Register  to view this content.

  20. #20
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    Have you tried the code (and attached workbook) I posted in post #18 ? Does that not do what you wanted?

  21. #21
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    thanks olly, sorry I'm trying to gets to grips with VBA and keep an eye on the forum, I'll give it a whirl now mate :-)

  22. #22
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    Olly, that is wonderful, there's just one small addition. Would it be possible to put the answer in "position" textbox and in width in text box width. I've updated the userform accordingly. But that is brilliant, fairplay!!!!.
    I'll attach the file
    Attached Files Attached Files

  23. #23
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    and put the readings in mm??????????? :-)

  24. #24
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    Okay, change this section of the code:
    Please Login or Register  to view this content.

  25. #25
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    That is beautiful!! Thank you ever so much, I've got plenty to keep my occupied now, Thank You Olly :-)

  26. #26
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    Happy to help. If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  27. #27
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: Converting a successful Excel Spreadsheet to a VBA based user form.

    As you are trying to learn, so I have attached this file, which will show you another way. I have used 2 dimensional array here.
    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. Excel user form vba code for next based on textbox value
    By mariec_06 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2015, 08:16 AM
  2. [SOLVED] User Form Txt Box calculation converting kg/min to T/Hour must show T/H and have comma
    By Colin Smit in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2014, 02:43 PM
  3. I wish to update details in specific rows in an Excel spreadsheet via a user form
    By Ashgaroth in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2013, 06:48 AM
  4. [SOLVED] Excel vba user form- open directly to user form not worksheet
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 04-24-2013, 05:07 PM
  5. [SOLVED] Excel user form- If/Then statement outcome to show on user form
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-18-2013, 09:16 AM
  6. Filter Excel Pivot, based on user entry form
    By Jayco in forum Excel General
    Replies: 1
    Last Post: 08-16-2006, 01: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