• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code to add data to table from manually created form

Neeno30

New Member
Good Afternoon:

I have created a manual form (not a UserForm) in Excel wherein users will input data. I would like to create a button linked to VBA code which will transfer some of the information into a table on another worksheet ("Database") and then clear the user form. For instance, cell F33 of my user form contains the data that will go in column A of my database, cell C7 of my user form contains the data that will go in column B of my database, so on and so forth. If anyone could help get me started on this code that would be great, I have been searching forums all day...

Thank you in advance for any assistance!

~Neeno
__________________________________________________________________
Mod edit : thread moved to appropriate forum !
 
Hi:

Could you upload a sample file. It will be much easier to code if we have template in place.

Thanks
 
Nebu:

Thank you for the quick reply! I assumed I would need to upload a sample file, I just had to take out some sensitive information. In any event, I attached a sample file which will give you an idea of what I am looking for. On the worksheet "Case Screening Form", users will input the necessary data in the form. I would like to add a button at the bottom which is linked to the VBA code. The code needs to add ("Case Screening Form" cell -> "Case Details" column):
I5 -> A
C7 -> B
C9 -> C
H10 -> D
H9 -> E
**If there is a value in G7 then -> F, Otherwise B5 -> F**
D49 -> G
H11 -> H
**If E29 = "X" then -> "Yes" in I; If E29 is blank then -> "No" in I
D31 -> J

Every time data is entered and the button is clicked I would like it to add the above information to a new record in a table on "Case Details", and then clear the form values entered.

I hope this helps, and thank you very much for your assistance!
 

Attachments

  • Investigations Database.xlsx
    15.2 KB · Views: 8
Hi:

I have coded for ADD , I am not sure I have assigned the right values to the right columns , you can change the cell references as per your need. I have added few more buttons to the sheet ( not coded yet), if you need these buttons it is fairly easy to code .

Thanks
 

Attachments

  • Investigations Database.xlsm
    22.8 KB · Views: 17
Nebu:

Thank you so much, the code worked flawlessly after I adjusted it a bit to fit my data/columns! I was hoping you might be able to help me with one more thing... I am creating another form workbook which will feed data into the database which you just helped me with. I can adjust the code you already provided me with the appropriate columns and whatnot; however, I need to qualify the original code to tell it to input the data in the different workbook. Specifically, the new workbook is called "Daily Activity Report" (worksheet "Daily Activity Report") and the data from there needs to feed into the original workbook "Investigations Database" (worksheet "Daily Activity Reports"). I am assuming it would only be a line or two to set the location of where the code needs to place the data...

Thank you in advance (again)!

~Neeno
 
I just realized something that will complicate what I am looking to do.... I have attached a copy of the form I created to make things a bit easier to understand.

The user will fill out their name and date (C4 and G4), and then complete their daily activities in the table below that (they will have multiple activities per day). So, I need the code to always add: Cell -> Column "Investigations Database" workbook, "Daily Activity Reports" worksheet
C4 -> B
G4 -> A
A7 -> C
C7 -> D
E7 -> E
G7 -> F
I7 -> G

This procedure needs to loop until column A of the source workbook is blank. So, a record will be added with the user's name, the date, and then the record from the source table then loop that until column A is blank. Is this possible?
 

Attachments

  • Daily Activity Report.xlsm
    17.9 KB · Views: 15
Hi:

I could not make out what you want here, what do you mean by this ?

I need the code to always add: Cell -> Column "Investigations Database" workbook, "Daily Activity Reports" worksheet
C4 -> B
G4 -> A
A7 -> C
C7 -> D
E7 -> E
G7 -> F
I7 -> G

The columns you specified here and the column headers you have in the "Investigations Database" workbook seems to be off , can you look into it and clarify further. It would be better if the filed names you have given in your data entry tab aligns with the headers in your database.

Thanks
 
Back
Top