copying data ranges

jaypatel

Active Member
Joined
Nov 25, 2002
Messages
389
Hi

I have 25 differently named spreadsheets located in c: my documents

but, within these 25 spreadsheets will be data range name labelled "Pay1".

how can i extract all these 25 "pay1" ranges into one sheet, but listed below each other?

cheers

Jay
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I would list all the filepaths in column A, then run the following code:

Code:
Sub ExtractData()
    Dim xlWb As Excel.Workbook
    Dim iCount As Integer
    Set xlWb = ActiveWorkbook
    For iCount = 1 To 25
        Workbooks.Open xlWb.Sheets(1).Cells(iCount, 1).Value
        xlWb.Sheets(1).Cells(iCount, 2).Value = ActiveWorkbook.Sheets(1).Range("Pay1").Value
        ActiveWorkbook.Close savechanges:=False
    Next iCount
End Sub

D
 
Upvote 0
Hi

Thanks for all your help.....

The code does work, but the code only copies the first sheet of data:

' Change this range to fit your own needs.
With mybook.Worksheets(1)
Set sourceRange = .Range("A1:C1")
End With

what i am hoping is for choosing range as "pay4"..... i have attempted to change the range as "pay4", but it does not work.

can anyone help?

cheers

Jay
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,521
Members
452,923
Latest member
JackiG

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