How to create user form under VBA for entering data

chintamani.avinash

New member
Joined
Sep 18, 2020
Messages
4
Reaction score
0
Points
0
Excel Version(s)
2016
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. 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 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. 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.
 
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.
 
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. 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 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. 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-pr...te-user-form-under-vba-for-entering-data.html
https://www.mrexcel.com/board/threads/how-to-create-user-form-under-vba-for-entering-data.1146126/
 
.
Download the example workbook here ----> https://www.amazon.com/clouddrive/share/i9K6qpVH4rL0fV9X3110ciBJcTAg4syfkw50NPc5USu

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.
 

Attachments

  • Data entry for form.xlsx
    10.6 KB · Views: 15
.
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.
 
.
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.
 
Back
Top