Obtaining data from closed workbooks

shakeregg

New Member
Joined
Sep 2, 2018
Messages
39
Hey all,

For some reason this is one that I'm really struggling with and I can't seem to get it right.

I have a main workbook (Main) which contains a worksheet called "Main Sheet". I also have two other workbooks called Sales1 (worksheet is "Sheet1") and Sales2 (worksheet is "Sheet2").

Both Sales1 (sheet1) and Sales2 (Sheet2) have text A2:C100.

What I'm trying to do is to find a Macro that is contained within the main workbook ("Main") and when activated obtains the data from Sales1 (sheet1) and Sales2 (sheet2) which are closed and pastes them into "Main" (Main Sheet) with one set of data going in A2:C100 and another in D2:F100.

If anyone can help it will be appreciated!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Have you tried recording a macro to open the workbooks and copy the data and then close and repeat for the second book and then stop recording that will give you a method.
 
Upvote 0
Yeah I tried that but when I run the macro it seems quite messy as it actively opens up the workbooks and shows the process in action. Is there a macro that wouldn't show this process happening?
 
Upvote 0
You can add to the code to stop seeing the updates, this example switches the application updating, warnings and auto calculation off at the beginning of the code , and then switches them all back once the code has run, it should also make the code run faster:

Sub clearUp()
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.Calculation = xlCalculationManual
End With
'Rest of your code goes here
With Application
.ScreenUpdating = True
.DisplayAlerts = True
.Calculation = xlCalculationAutomatic
End With
End Sub
 
Upvote 0
Happy to help and thanks for letting me know it helped.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,264
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top