View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Arlen Arlen is offline
external usenet poster
 
Posts: 86
Default Gathering data from multiple, non-contiguous ranges

Hello, Everyone!

I know this question has been asked many times and dealt with in many ways,
but I don't know how to modify it for my personal dilemma. I found this code
in another forum for copying a single range from all sheets of all books in a
folder to a single new master sheet.

Code:
Sub Open_All_Files2()
Dim oWbk As Workbook
Dim w As Worksheet
Dim sFil As String
Dim sPath As String
Dim k As Long, n As Long
sPath = "C:\Documents and Settings\gl1b\Desktop\Tacoma 2007\"
ChDir sPath
sFil = Dir("*.xls") 'change or add formats
Application.DisplayAlerts = False
k = ThisWorkbook.Sheets(1).Range("A65536").End(xlUp).Row
    n = k + 1
Do While sFil < ""
    k = ThisWorkbook.Sheets(1).Range("A65536").End(xlUp).Row
    n = k + 1
    Set oWbk = Workbooks.Open(sPath & "\" & sFil)
    Range("A13:J27").Copy
    Set w = ThisWorkbook.Sheets(1)
        ThisWorkbook.Sheets(1).Range("A" & n).PasteSpecial
oWbk.Close True
sFil = Dir
Loop
Application.DisplayAlerts = True
End Sub
I ran it and it seems to open, copy and close everything in the folder I
specified. I just don't see the pasted data anywhere.

My specifics are these:

I need to copy everything from B4 to B?? <-- wherever the data in col B runs
out, C4 to C?? and N4 to N??, paste it continuously down Cols A, B and C of a
new master sheet.

I have puzzled over this code for 2 days, changing things and changing them
back when it didn't work. If anyone could make the necessary tweaks, I would
appreciate it tremendously.

Thanks for your time.

Arlen