Sep 17 2023 10:38 PM
Hi
I have a spreadsheet with 2 sheets.....Sheet A (data) and Sheet B (input). I have created a table in A and managed to create a data entry form. In sheet B I created a button and attached a macro which opens A and the data entry form.
The first problem I have is that whenever I try to enter data I get "Cannot extend table or database".
Now this is my wishlist...please note that I am not fluent in VBA etc.
1. Can I create a data entry form that is always displayed in B to enable creation of new data and searching?
2. How do I get rid of the error I am currently getting?
I was hoping to attach a sample but can't see where to do that.
Many thanks
Debbie
Sep 17 2023 10:48 PM
It seems like you are trying to create a data entry form in Excel 365 that allows you to input data into a table and perform searches. To address your questions:
Step 1: Create a UserForm
Step 2: Code the UserForm
Next, you will need to write VBA code to handle interactions with the UserForm. For example, you will write code to add data to your table when the user clicks a "Submit" button.
Here is a simple example of VBA code to add data to a table:
vba code:
Private Sub SubmitButton_Click()
Dim ws As Worksheet
Dim tbl As ListObject
Dim newRow As ListRow
' Set the worksheet and table
Set ws = ThisWorkbook.Sheets("SheetA")
Set tbl = ws.ListObjects("TableName") ' Replace "TableName" with your table name
' Add a new row to the table
Set newRow = tbl.ListRows.Add(AlwaysInsert:=True)
' Fill in data from UserForm controls
newRow.Range(1, 1).Value = TextBox1.Value ' Replace with your control names and values
' Close the UserForm
Unload Me
End Sub
Step 3: Show the UserForm
You can add a button to Sheet B and attach code to display the UserForm when clicked. Here's a simplified example:
vba code:
Private Sub ShowFormButton_Click()
UserForm1.Show ' Replace "UserForm1" with your UserForm's name
End Sub
The "Cannot extend table or database" error typically occurs when you are trying to add data to a table, and Excel is unable to determine the table's size correctly. You can try the following steps to resolve this issue:
By creating a UserForm for data entry in Sheet B and handling data submission through VBA code, you can achieve your goal of entering and managing data more effectively. The text, steps and codes were created with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark them as helpful and like it!
This will help all forum participants.
Sep 18 2023 12:15 AM
Thanks so much....I am amazed that I have got this far so far....still a way to go.
I have created the user form:
I tried applying the code to 'submit' and 'new entry' as you can see i have a problem with the latter.
I appreciate your patience (this is all new to me) but what have i done wrong to get the error and how do i test the user form.
I am not sure how to open the excel spreadsheet with the user form displayed.
Code for the 'search' would be great