![]() |
#1
|
|||
|
|||
![]()
Hi,
I'm trying to loop through all open workbooks excluding the one I'm working in as the master workbook and want to copy the first two cells (A1:A2) in each workbook in each sheet, back to the workbook that I'm working in. Here is the code I have so far, but I keep getting a runtime error '438': Sub Macro1() ' ' Macro1 Macro ' Dim wb As Workbook Dim ws As Worksheet Dim myrange As Range Dim i As Long For Each wb In Application.Workbooks If wb.Name <> "Book1.xlsx" Then For Each ws In wb.Sheets() For i = 3 To i + 2 ws.Range("A1:A2").Copy Destination:=Windows("Book1").Sheets("Sheet1").Ran ge(Cells(i, 1), Cells((i + 1), 1)).String Next i Next ws End If Next wb End Sub |
Tags |
copy, for each loop, for loop |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
donlincolnmsof | Word VBA | 11 | 09-07-2017 10:07 PM |
![]() |
Twizzle008 | Word VBA | 15 | 09-18-2015 03:20 PM |
What's wrong with my loop? | Irrma | Word VBA | 2 | 06-17-2014 06:25 AM |
![]() |
Jennifer Murphy | Word VBA | 1 | 01-29-2013 03:30 AM |
![]() |
cksm4 | Word | 6 | 01-06-2011 09:03 PM |