• 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: Reference values from one workbook to another workbook (various worksheets)

inddon

Member
Hi There,

I have 2 workbooks where I would like to have data from one workbook worksheet to various worksheets in another workbook. The requirement is as below:

Please find attach the below sample files for your reference.

A. Source Data.xls
The first file has the raw data from a system that is fetched in the excel workbook worksheet 'Raw Data'

B. Template Report.xlsx
The second file is the template report which has a lot of dashboard functionality which is based on the above workbook data. It has has various worksheets 'Raw Data x' that is based on the above first file.

The first option: I was thinking of referencing the cells from first file in the second file, that would be the quickest.
But the problem here is only the second file will be send to various departments and not both the files. In such a case the option of referencing seems will not work.
Like to know what your feedback on this would be

The second option: is to create a button in the second file which will have the VBA code to fetch data from the first file into the second file
eg. In the second file, worksheet setup, the following columns will be there:
1. The path of the first file: <File Path>
2. The name of the first file: <Name of the File>
3. Data Fetched (Yes or No): <A value Yes after the program is Run>
4. Data Fetched Date: <Date when the program is run>
5. Total Data Fetched: <Total Rows fetched>

The above 1 & 2 will be User input, and the remaining will be filled by the program

A button (VBA code) which will do the following:
-Check if the path and file name exists. If not display message source data file does not exists
-If path of source file and file exists in the given directory then continue with the fetching of data from the first file to the second file
- When the program is finished, display the above values for point 3 to 5)
Below column mappings:
-------------------- -------------------------
Template Report.xlsx Source Data.xls
-------------------- -------------------------
Worksheet (Raw Data 1) Worksheet (Raw Data 1)
COLUMN NAMES = COLUMN NAMES
-Child ID = Child ID
-First Name = First Name
-Gender = Gender

Worksheet (Raw Data 2) Worksheet (Raw Data 1)
COLUMN NAMES = COLUMN NAMES
-Child ID = Child ID
-First Name = First Name
-Last Name = Last Name
-Gender = Gender

Worksheet (Raw Data 3) Worksheet (Raw Data 1)
COLUMN NAMES = COLUMN NAMES
-Child ID = Child ID
-First Name = First Name
-Last Name = Last Name
-Gender = Gender
-Date of Birth = Date of Birth

Look forward to hearing from you.

Regards,
Don
 

Attachments

  • Template Report.xlsx
    22.6 KB · Views: 3
  • Source Data.xls
    49 KB · Views: 2
Back
Top