Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

How to use userform to get inputs and store data in another workbook.

0

Hi, I have seen your tutorial on userform to get inputs to store data in another worksheet (tab). However, can you also show to store data in another workbook (excel database)?

Answer
Discuss

Discussion

In the code - if you show me the code I can show you where - the workbook to which the data are written is specified. However, that other workbook needs to be open, meaning you need to manage it which is done by code you probably don't have yet. You should consider carefully whether the extra effort is worth whatever benefit you might get from having the code that writes to your database in another workbook. The benefits I can imagine are all administrative, meaning they are not practical. Usually, when a business starts to make rules to please itself it loses touch with its own reality. In other words, administrative benefits shouldn't outweigh the practical ones.
Variatus (rep: 4889) Sep 22, '20 at 7:56 pm
Add to Discussion

Answers

0

You would do something like this:

Sub test()

    Dim wbDatabase As Workbook

    Set wbDatabase = Workbooks.Open("C:\Test\Test.xlsx")

    wbDatabase.Worksheets("Data Sheet").Range("A1").Value = "Your Value"

    wbDatabase.Close SaveChanges:=True

End Sub

C:\Test\Test.xlsx is the full path to the other workbook.

Data Sheet is the name of the sheet to put the data on in the other workbook.

Range("A1") is the range reference that controls into which cell the data goes.

This template should get you going.

Discuss


Answer the Question

You must create an account to use the forum. Create an Account or Login