View Single Post
 
Old 09-07-2018, 08:28 AM
NoSparks NoSparks is offline Windows 7 64bit Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Where is your code located ?
Are you sure "Book1.xlsx" is right ?


Does something like this work
Code:
Sub Macro1()

Dim wb As Workbook, ws As Worksheet, i As Long

'cycle through all open workbooks
For Each wb In Application.Workbooks
    'check if it's thisworkbook <~~ ie: the one holding this code
    If wb.Name <> ThisWorkbook.Name Then
        'when it's not thisworkbook
        With wb
            'cycle through the sheets in wb
            For Each ws In wb.Sheets
                'determine where to write data in thisworkbook
                i = ThisWorkbook.Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1).Row
                'first write is to start at row 3
                If i < 3 Then i = 3
                'copy values to thisworkbook from ws
                ThisWorkbook.Sheets("Sheet1").Cells(i, 1).Resize(2).Value = ws.Range("A1:A2").Value
            Next ws
        End With
    End If
Next wb

End Sub
Reply With Quote