Copy different ranges from several sheets from closed Workbook

sampson32

Active Member
Joined
Jul 16, 2003
Messages
312
Office Version
  1. 2021
Platform
  1. Windows
I’ve started with Ron de Bruin’s “Copy a range from closed workbooks (ADO)” to access and pull data from a closed workbook. (It has a VBA sequence password that makes it difficult to open programmatically)

Using the “GetData” routine below…

****************************

Sub GetData_Example3()

GetData "\\CCServer01\cc apps\Branch Count.xls", "Tampa", "B8:N12", Sheets("Total Count").Range("E5"), False, False

End Sub

****************************


This code works as expected – it pulls the values from the “Branch Count Workbook / Tampa sheet / range “B8:N12” and places the copied range in the Active Workbook on sheet “Total Count” starting in cell E5.

I actually need this code to go a little further…

I need to copy 2 separate ranges from 10 different sheets in the Branch Count Workbook and deposit the copied values in 2 seperate ranges on the ‘Total Count’ sheet.

Something like this – using the above code I stared with…

Copy values from the Branch Count Workbook on sheet “Tampa” the separate ranges B8:N12 and T6:T16 and have the values deposited on the active sheet “Total Count” starting in ranges E5 and X5 respectively.

The 2 separate range areas of each sheet that has values copied and the 2 seperate range areas to populate on the Total Count spreadsheet are not identical.

Is there a way to get the “GetData” code to handle more than 1 sheet and 1 range?

Thanks...
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Why not just run the GetData again with different parameters instead of rewriting the function?
 
Upvote 0
From my limited knowledge it seems the "GetData" calls and runs the ADO -the focus then goes back to the start (GetData).

do I need to run the complete ADO code for each seperate GetData line of code that would be created or is there a way to integrate the several GetData's with the same ADO code.

I hope I'm clear on my question?

Thanks...
 
Upvote 0
I've not seen the code for the function - I think you need to download a workbook for that but I would assume it does all the ADO stuff.

So you don't need to worry about that part.

What you do need is a way to 'easily' pass the parameters to the function for multiple workbooks/sheets/ranges.

You could probably do that with some sort of array/arrays.

Or perhaps create a list on a worksheet of the source workbooks/sheets/ranges and the destinations.

Then you would loop through either, get the parameters and call the function with the parameters.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,712
Members
452,939
Latest member
WCrawford

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