Forum Discussion
iapetustitan
Nov 13, 2020Copper Contributor
Populating cell data from one workbook to another - checkboxes/buttons/VBA?
Hi there. Looking for some info on auto populating certain cells with certain data from one spreadsheet to another. Two sheets attached. The 'Test_draft_1' is a first draft idea for a (large) stock/...
NikolinoDE
Nov 13, 2020Platinum Contributor
Here is a VBA example, untested.
Sub data_walk ()
Dim wbA As Workbook
Dim wbB As Workbook
Dim wbNeu As Workbook
'Open the "B.xls" file if it is not already open
Application.DisplayAlerts = False
Workbooks.Open Filename: = "C: \ Code \ B.xls"
Application.DisplayAlerts = True
Set wbA = Workbooks ("A.xls")
Set wbB = Workbooks ("B.xls")
'create new workbook .... will later be "C.xls"
Application.Workbooks.Add
Set wbNeu = ActiveWorkbook
'Example: cells A1 and A2 from folder "B.xls" are multiplied together
'and the result is written into the new folder / cell A1
wbNeu.Sheets (1) .Range ("A1") = wbB.Sheets (1) .Range ("A1") * wbB.Sheets (1) .Range ("A2")
'The folder is saved as "C: \ Code \ C.xls"
Application.DisplayAlerts = False
wbNeu.SaveAs Filename: = "C: \ Code \ C.xls"
Application.DisplayAlerts = True
'Folder "B.xls" is closed (without saving)
Application.DisplayAlerts = False
Workbooks ("B.xls"). Close
Application.DisplayAlerts = True
End SubFor the example, the "B.xls" file should contain numbers in cells A1 and A2.
The macro is started from file "A.xls" and opens file "C: \ Code \ B.xls \" (if not already open), cells A1 and A2 are multiplied from this file and the result in cell A1 in the new file "C: \ Code \ C.xls \".
Fished from the internet ... don't ask me where, believe from some german site.
Simply sent as an example, it may help you in your project.
Hope I was able to help you.
Nikolino
I know I don't know anything (Socrates)
* Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here
- iapetustitanNov 13, 2020Copper Contributor
NikolinoDE Thanks, I'll take a look at that.