VBA question convert form(s) into a database

cyrilbrd

Well-known Member
Joined
Feb 2, 2012
Messages
4,113
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Good day,
Given an excel form filled up by users, said form contains several fields and data.
I would like to convert these into a database by copying the data to the next empty row.
Example of the form:
Book1.xlsm
ABCDEFG
1Form filled up and printed by user
2
3desig11
4desig22
5desig33
6desig44
7
8tbl1field1field2field3field4
9Type15678
10Type29101112
11Type313141516
12Type417181920
13Type521222324
14
15tbl2field5field6field7field8field9field10
16Type6252627282930
17Type7313233343536
18Type8373839404142
19
20tbl3field11
21Type943
22Type1044
23Type1145
form


And this is how the database would look like, with each subsequent iteration of the form copied to the next empty row, thus allowing extraction of data from the created DB via formulae or pivot...
Book1.xlsm
ABCDEFGHIJKLMNOP
28desig1desig2desig3desig4TypeField1Field2Field3Field4Field5Field6Field7Field8Field9Field10Field11
291234Type15678
301234Type29101112
311234Type313141516
321234Type417181920
331234Type521222324
341234Type6252627282930
351234Type7313233343536
361234Type8373839404142
371234Type943
381234Type1044
391234Type1145
form

Any suggestion would be welcome.
The idea would be for the file to have only two (2) tabs, on for the form, and one for the DB, the user would encode the form and 'copy' it to the DB via vba.
Thanks.
 
Last edited:
Thanks for the code, I definitely learned something.
Added to other routines, will test it properly tomorrow morning.
Will get back to this thread for any follow up.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I will post a new thread, Same setup but this time I would like to ADD specific fields so the running total would be updated accordingly.
 
Upvote 0
Good day, Given the same setup with slight variations:
Form is unchanged:
Book1.xlsx
ABCDEFG
1Form filled up and printed by user
2
3desig11
4desig22
5desig33
6desig44
7
8tbl1field1field2field3field4
9Type15678
10Type29101112
11Type313141516
12Type417181920
13Type521222324
14
15tbl2field5field6field7field8field9field10
16Type6252627282930
17Type7313233343536
18Type8373839404142
form


The database however was modified as follows:
Book1
ABCDEFG
1desig1desig2desig3desig4TypeCatValues
21234Type1field15
31234Type2field19
41234Type3field113
51234Type4field117
61234Type5field121
71234Type1field26
81234Type2field210
91234Type3field214
101234Type4field218
111234Type5field222
RawDB


The modification allows better extraction.
I tried to recall the data using a simple formula such as:
Excel Formula:
=IFERROR(INDEX(RawDB!$G$2:$G$11,MATCH(1,($A9=RawDB!$E$2:$E$11)*(C$8=RawDB!$F$2:$F$11),0)),"")
But I get a DEBUG message for the following:
VBA Code:
    WS.Range("C9").Formula = "=IFERROR(INDEX(RawDB!$G$2:$G$11,MATCH(1,($A9=RawDB!$E$2:$E$11)*(C$8=RawDB!$F$2:$F$11),0)),"")"

I was hoping to be able to recall the info from the table using this kind of formula but am wondering what I am doing wrong.
Thanks for any input.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top