How to input data from another workbook

0

I wanna ask something about VBA macro excel. i have a database in workbook excel. I wanna input data (call) some cell from database workbook in new workbook. so, do you know how to call them ?

Answer
Discuss

Answers

1
Selected Answer

You want to use a macro like this:

Sub get_data()

Dim Wb1 As Workbook

'Dont update the screen - makes it work faster
Application.ScreenUpdating = False

'Open the other workbook
'Input the FULL path to the file, including its extension
Set Wb1 = Workbooks.Open("C:\sample.xls")

'You can do whatever you want here with the other workbook - it is now open.
'This just copies some cells.
Wb1.Sheets(1).Range("A1:A10").Copy

'Close the workbook from which we just got some data and make sure not to save it in case accidental changes were made to it.
Wb1.Close SaveChanges:=False

'Turn on screen updating again - makes Excel usable
Application.ScreenUpdating = True

End Sub

This will copy some cells by default but you can do anything with the data and then put it into the other workbook.

There is a tutorialfor this macro and it explains things in more detail.

This is basically what you need but if you need more help, then update your question and provide some sample files and more information.

Discuss

Discussion

this is my DB:





and this is my new workbook as engine that will running the program.







my question is, when i write the code in my new workbook (B4) i wanna the quality values will show in cell C4 until G4 automatically depend on my database. Please help me. Thank you..... :)
twittalinee (rep: 2) Jul 21, '16 at 8:32 am
Add to Discussion
0

this is my DB:





and this is my new workbook as engine that will running the program.







my question is, when i write the code in my new workbook (B4) i wanna the quality values will show in cell C4 until G4 automatically depend on my database. Please help me. Thank you..... :)

Discuss

Discussion

Update your original question with this information and then delete this "Answer" please. (It was clearly stated that you should do this where you clicked the link to input the Answer.)
don (rep: 1247) Jul 21, '16 at 11:57 am
Add to Discussion
0

Best twittalinee,

You don't need VBA to get this result.

I changed your files a little bit.
I made two tables. One in each file.

"Quality.xlxs" contains table "tblQuality"
"Engine.xlsx" contains table "tblEngine"
The cells in column "No." you can fil in a number that exist in "quality.xlsx".
The other columns contains a formula "Vlookup"

Make shure both files are opened.
Ad a new line in "engine.xlsx" by filling in a number in the cell unther the last cel in column "A".
If the number exists in "tblQualitiy", the other values appear.

I already filled in some numbers in "tblEngine", to let you see that the values are equal to te values in "tblQuality"

Discuss

Answer the Question

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