+ Reply to Thread
Results 1 to 16 of 16

VBA Userform help

  1. #1
    Registered User
    Join Date
    06-28-2015
    Location
    North East, England
    MS-Off Ver
    2010
    Posts
    39

    VBA Userform help

    Hi can someone help me please I have a userform i have created. I have created a a portal of links to forms, one of the forms i have made using a UserForm (System_Access) and it has Textboxs, 2 comboboxs and a number of checkboxs. Once the form is completed and send is pressed the information needs to be copied to an external sheet (DataSheet) and then sends a email.

    The Email works fine but Im having great difficulty with code for the Combobox and coping the textbox, checkbox data across to the DataSheet. It needs to be possible when more than one checkbox is selected then the name of that box is copied to the DataSheet possibly a listbox.

    Can anyone help with me with some code to 1) create the combobox 2) copy the info to the Datasheet. I have attached the example of the 2 sheet for reference.

    Thank you in advance
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Userform help

    Hello stanton17,

    I have a few questions about your UserForm. You have a lot of CheckBoxes. These are generally used for multiple choice. Which Checkboxes are multple choice and which are not?

    You say in your email "A System Access request has been submitted. Please click on the link below for the details". Do you want a working link in the email?

    Can you provide a list of job titles that the ComboBox is to display?

    Why is this code in the UserForm?
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    06-28-2015
    Location
    North East, England
    MS-Off Ver
    2010
    Posts
    39

    Re: VBA Userform help

    Hi Leith

    Thank you for your reply and interest.

    1)The checkboxs are to select certain types of system access to request for another computer system, its possible to have multiple types. What i wanted is when boxes are checked the checkbox name is copied to the datasheet, maybe into dropdown list. do you think it would be better to do the job multi-select list on the userform that copies to a dropdown list on the datasheet?

    2)Once the coding for the userform is complete i will put a working link on the email, the spreadsheet i have attached is a sample of the original one i created.

    3)Combobox1 needs to show AA,AO,EO,HEO and Combobox2 needs to show a list of teams, an example is Telephony, Claims and reporting.

    4)The code you displayed was when i was trying populate combobox1 by using a defined name called JobRole linked to hidden column U. I couldn't get it to work, i should have deleted it.

    Are you able to help?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Userform help

    Hello stanton17,

    Thanks for answering my questions. What you are trying to do makes sense now.

    A drop down could be added to the worksheet to display the check box choices. Have you considered creating and using a comma separated list? This could be displayed in the cell.

    The advantages are it is less coding and easier to update. A drop down usually suggests the user make a choice from the list. This could be confusing to other users.

  5. #5
    Registered User
    Join Date
    06-28-2015
    Location
    North East, England
    MS-Off Ver
    2010
    Posts
    39

    Re: VBA Userform help

    Hi Leith

    Yes a comma separated list on the datasheet sounds a great idea.

    Can you help me with coding for the comboboxs, tranfser of data to Datasheet and comma separated list?

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Userform help

    Hello stanton17,

    I am working on it right now.

  7. #7
    Registered User
    Join Date
    06-28-2015
    Location
    North East, England
    MS-Off Ver
    2010
    Posts
    39

    Re: VBA Userform help

    Thank you Leith

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Userform help

    Hello stanton17,

    This took longer than I expected. There are still some things that need attention like where do the job roles go on the data sheet? There a few more things like that we can patch as we go.

    The System and Job check boxes have been sub-classed. This allows the controls to execute the same macro code. The usual method is write the code into each object's click event. With as many of the check boxes as you have, this isn't really an option. Sub-classing is a more advanced technique and can be a little difficult to understand but it is much more flexible.

    I added some code to remove the close X from the user form. There is nothing more annoying than clicking on the close X and being told to use a button on the form. Most people do it that way because they don't how to get rid of the close X. I also upgraded the look of your buttons.

    Try this out and let me know you think.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-28-2015
    Location
    North East, England
    MS-Off Ver
    2010
    Posts
    39

    Re: VBA Userform help

    Leith

    Thank you loads for your work on this and working with me, removing the close x is a good idea and i like the look of the buttons.

    The items Access for your job role need to populate into another column called Access, before the system item column, it need to work the same way as the system item. I have missed a couple of column,oops. We need a Remove access Yes on the datasheet when the box is ticked on the user form. problem with this is if the remove access is checked the "Access to job role" boxs will not be checked. Also we need a Authoriser grade textbox on the userform under line manager and it will need to copy into the datasheet.

    The Datasheet will not be used by the people completing the form and dont really need to see it, so i need the Datasheet to automatic open when the uerform is opened and then close when the userform is closed. i may be able to do this myslef. The datasheet is going to be used by admin to add and update users access.

    One more thing could you make the date automacticlly populate with todays date and then copy to the datasheet. or i could remove the userform date field and auto populate the date when the datasheet is opened.

    Thank you again, is it possoble to give some one more than one reputation?

    Paul

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Userform help

    Hello Paul,

    I anticipated the need for the "Remove Access" check box being set to true. The Access check boxes operate the same the System check boxes. All the check boxes produce a comma separated list. The sub-classing I mentioned in my last post is what makes this possible without a thousand lines of code.

    I will add the needed columns and the text box. What about ComboBox2? What is it and where should its contents go on the worksheet?

  11. #11
    Registered User
    Join Date
    06-28-2015
    Location
    North East, England
    MS-Off Ver
    2010
    Posts
    39

    Re: VBA Userform help

    Hello leith
    Combobox2 needs to show a list of teams, an example is Telephony, Claims and reporting. And go onto datasheet after the fist combo box data. I have decided to make the user form landscape as not all users have the same resolution and it's possible having the form portrait that the bottom could get chopped, also think it looks better.

  12. #12
    Registered User
    Join Date
    06-28-2015
    Location
    North East, England
    MS-Off Ver
    2010
    Posts
    39

    Re: VBA Userform help

    Hello leith

    I have the spreadsheet working great at work, thank you.

    The only things left to do that I can't figure out is the system check boxs. Also I have the datasheet to open automatically when the userform is opened. What I can't work out is for the datasheet to minamize or hide and then save n close when the close button is pressed on the userform. The users who complete the userform do not have any interaction with the datasheet.

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Userform help

    Hello Paul,

    I added the columns to the DataSheet and have the "Remove Access" check box marking the column with "Yes" when true. When the check box is true all other Job Access check boxes are cleared.

    The UserForm is now resizable. This should you with the different screen sizes. Move the mouse to the edge of the form and you will see the cursor change. Left click and drag to change the user form's size.

    The DataSheet is opened when the main workbook is opened. However, it does not close when the main workbook closes. The macro has the path for the DataSheet set to the same folder as the main workbook. You can change this path if you need to in the Workbook_Open event of the main workbook. This only place you need to make changes to either the DataSheet workbook path or name.

    The UserForm can be closed from the keyboard using either the Esc key or by using ALT+F4. Sometimes it is not convenient to click the close button.

    Try the new workbook and let me know what you think and what may need updating.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    06-28-2015
    Location
    North East, England
    MS-Off Ver
    2010
    Posts
    39

    Re: VBA Userform help

    Hello Leigh

    Thank you, the resize userform code is really clever.

    The remove Yes/No needs to only copy the name feilds, Authorizer/Manager name, grade and the date over to the datasheet. How would i amend the code to do that. Would you be able to write a bit code for the userform close button so so when it is clicked the datasheet is closed and post it here.

  15. #15
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Userform help

    Hello Paul,

    I am a bit confused by this...
    The remove Yes/No needs to only copy the name feilds, Authorizer/Manager name, grade and the date over to the datasheet.
    Are you referring to the "Please Remove Access" check box?

  16. #16
    Registered User
    Join Date
    06-28-2015
    Location
    North East, England
    MS-Off Ver
    2010
    Posts
    39

    Re: VBA Userform help

    Hi Leigh

    Sorry for not replied until now, I have been on holiday. I have managed to resolve the problem I had and I put a beta version out to a small number of people on a pilot, 2 weeks ago. I took comments today and the users liked it and there was no negative comments.

    Thanks for your help with this

    Paul

+ 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] Save data from UserForm into Sheet (how to resolve runtime errors in UserForm tutorial)
    By eighty6 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-14-2015, 07:41 PM
  2. Userform Combobox - select from list, store this as default each time userform loads
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-19-2014, 07:48 AM
  3. combining chart userform and data transfer userform into 1 userform
    By H_Kennedy in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-04-2014, 07:11 AM
  4. combining chart userform and data transfer userform into 1 userform
    By H_Kennedy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-03-2014, 12:28 PM
  5. [SOLVED] Changed userform combobox to listbox, unable to get userform to retrieve datasheet values
    By dragonabsurdum in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-29-2013, 01:38 PM
  6. [SOLVED] Open a userform from a userform, but preserve the info in the original userform
    By jfoerch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-25-2013, 02:38 PM
  7. userform is large.....how to use scrollbar of userform to show all of the userform
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2010, 04:11 PM

Tags for this Thread

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