Results 1 to 7 of 7

Thread: How to create user form under VBA for entering data

  1. #1
    Neophyte chintamani.avinash's Avatar
    Join Date
    Sep 2020
    Posts
    4
    Articles
    0
    Excel Version
    2016

    How to create user form under VBA for entering data



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hello friends,
    I want to enter data in sheet 1 using user form having based of VBA coding. My requirement is that,

    1. I want button on sheet 1 by the name 'Enter Data'. When i click on that button user form will be open up.

    2. I have table in sheet 1 in which i want to enter data. Fields in the table are [a] Sr. No. [b] Date [c] Name of the Category [d] Items under Category [e] Quantity.

    3. Important thing is that, menu of '[d] items under category' is dependent to '[c] Name of the Category'.

    I have following three categories in my shop: Fruits, Vegetables and Dry Fruits.
    Under each of the category following items are includes:
    Fruits: Apple, Orange, papaya, grapes and Kivi.
    Vegetables: Ladyfinger, coli-flower, cabbage and eggplant
    Dry fruits: Almonds, cashews, walnuts, pistachio and dates.

    Under this i want dependent list. Means if i click on Fruits, in the next cell list of fruits should be auto-populated so that i can select one them. If i select vegetables then in the next cell list of vegetables should be auto-populated so that i can select one of them, and so on in case of Dry fruits. But if i go to previous cell of '[c] Name of the Category' then next cell should be automatically changed its options as per previous cell on which it is dependent.

    4. Data entry in sheet 1 is expected to be start from
    cell A4 for [a] Sr. No., Cell B4 for [b] Date, C4 for [c] Name of the Category, Cell D4 for [d] Items under Category, E4 for [e] Quantity.
    If possible Sr. no. should be auto-populated.

    5. Date should in the format dd-mm-yyyy

    6. I also need following functions / buttons / options on user from: Add Data, Search Data, Edit Data, Delete Data.

    6. If possible under Search Data options, search can be done by various criteria as per [a] Sr. No. [b] Date [c] Name of the Category [d] Items under Category [e] Quantity.

    7. Some times Quantity remains in decimal form e.g. 11, 12.50 which should not be changed. Means 12.50 should be 12.50 and not 12.5

    I have also attached file for understanding of table.

    Thank you for your help in advance. This will be your great help.

  2. #2
    Administrator Pecoflyer's Avatar
    Join Date
    Oct 2011
    Location
    Brussels Belgium
    Posts
    1,721
    Articles
    0
    Excel Version
    2010 on Xubuntu
    Hi and welcome
    Please,do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    If you have fewer than 10 posts here, you will not be able to post a link, but you must still tell us where else you have asked the question

    Do not post any further responses in this thread until a link has been provided to these cross posts.
    Thank you Ken for this secure forum.

  3. #3
    Neophyte chintamani.avinash's Avatar
    Join Date
    Sep 2020
    Posts
    4
    Articles
    0
    Excel Version
    2016
    Quote Originally Posted by chintamani.avinash View Post
    Hello friends,
    I want to enter data in sheet 1 using user form having based of VBA coding. My requirement is that,

    1. I want button on sheet 1 by the name 'Enter Data'. When i click on that button user form will be open up.

    2. I have table in sheet 1 in which i want to enter data. Fields in the table are [a] Sr. No. [b] Date [c] Name of the Category [d] Items under Category [e] Quantity.

    3. Important thing is that, menu of '[d] items under category' is dependent to '[c] Name of the Category'.

    I have following three categories in my shop: Fruits, Vegetables and Dry Fruits.
    Under each of the category following items are includes:
    Fruits: Apple, Orange, papaya, grapes and Kivi.
    Vegetables: Ladyfinger, coli-flower, cabbage and eggplant
    Dry fruits: Almonds, cashews, walnuts, pistachio and dates.

    Under this i want dependent list. Means if i click on Fruits, in the next cell list of fruits should be auto-populated so that i can select one them. If i select vegetables then in the next cell list of vegetables should be auto-populated so that i can select one of them, and so on in case of Dry fruits. But if i go to previous cell of '[c] Name of the Category' then next cell should be automatically changed its options as per previous cell on which it is dependent.

    4. Data entry in sheet 1 is expected to be start from
    cell A4 for [a] Sr. No., Cell B4 for [b] Date, C4 for [c] Name of the Category, Cell D4 for [d] Items under Category, E4 for [e] Quantity.
    If possible Sr. no. should be auto-populated.

    5. Date should in the format dd-mm-yyyy

    6. I also need following functions / buttons / options on user from: Add Data, Search Data, Edit Data, Delete Data.

    6. If possible under Search Data options, search can be done by various criteria as per [a] Sr. No. [b] Date [c] Name of the Category [d] Items under Category [e] Quantity.

    7. Some times Quantity remains in decimal form e.g. 11, 12.50 which should not be changed. Means 12.50 should be 12.50 and not 12.5

    I have also attached file for understanding of table.

    Thank you for your help in advance. This will be your great help.
    Message also posted for responses:
    https://www.excelforum.com/excel-pro...ring-data.html
    https://www.mrexcel.com/board/thread...-data.1146126/

  4. #4
    Conjurer Logit's Avatar
    Join Date
    Nov 2016
    Posts
    267
    Articles
    0
    Excel Version
    2007
    .
    Download the example workbook here ----> https://www.amazon.com/clouddrive/sh...syfkw50NPc5USu

    You can edit the workbook to fit your needs. This example is a very basic representation of constructing a small database, which is what you are attempting to do.

  5. #5
    Neophyte chintamani.avinash's Avatar
    Join Date
    Sep 2020
    Posts
    4
    Articles
    0
    Excel Version
    2016
    Quote Originally Posted by Logit View Post
    .
    Download the example workbook here ----> https://www.amazon.com/clouddrive/sh...syfkw50NPc5USu

    You can edit the workbook to fit your needs. This example is a very basic representation of constructing a small database, which is what you are attempting to do.

    Thanks for your reply. I need dependent dropdown list as per the given requirement in description. Dropdown should be selected from the list which is in another sheet in the same workbook.
    Attached Files Attached Files

  6. #6
    Conjurer Logit's Avatar
    Join Date
    Nov 2016
    Posts
    267
    Articles
    0
    Excel Version
    2007
    .
    It is time to learn VBA coding ...

    Code:
    Private Sub btnOK_Click()
        Dim ws As Worksheet
        Set ws = ActiveSheet
        Dim newRow As Long
        
        newRow = Application.WorksheetFunction.CountA(ws.Range("A:A")) + 1
        
        'The next two lines can be expanded as many times as needed for all the entry fields in your project
        
        ws.Cells(newRow, 1).Value = Me.txtFirstName.Value
        ws.Cells(newRow, 2).Value = Me.txtSurname.Value
        
    End Sub
    Where you see ... Me.txtFirstName.Value ... change that to your DropDown/ComboBox value .

    There are tons of examples on the internet ... Google is your friend.

    Start to build your project with this portion. Then move on to the other requirements of your project and when you get stuck, return here for assistance.

    If you are wanting someone to build the entire project for you, there is a Commercial Section in this Forum where you pay someone for the project.

  7. #7
    Neophyte chintamani.avinash's Avatar
    Join Date
    Sep 2020
    Posts
    4
    Articles
    0
    Excel Version
    2016
    Quote Originally Posted by Logit View Post
    .
    It is time to learn VBA coding ...

    Code:
    Private Sub btnOK_Click()
        Dim ws As Worksheet
        Set ws = ActiveSheet
        Dim newRow As Long
        
        newRow = Application.WorksheetFunction.CountA(ws.Range("A:A")) + 1
        
        'The next two lines can be expanded as many times as needed for all the entry fields in your project
        
        ws.Cells(newRow, 1).Value = Me.txtFirstName.Value
        ws.Cells(newRow, 2).Value = Me.txtSurname.Value
        
    End Sub
    Where you see ... Me.txtFirstName.Value ... change that to your DropDown/ComboBox value .

    There are tons of examples on the internet ... Google is your friend.

    Start to build your project with this portion. Then move on to the other requirements of your project and when you get stuck, return here for assistance.

    If you are wanting someone to build the entire project for you, there is a Commercial Section in this Forum where you pay someone for the project.

    Thanks for your help. I will try with your help. In case any assistance i will be back. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •