View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
dim dim is offline
external usenet poster
 
Posts: 123
Default Specifying Cells To Copy Across Workbooks Not Working!

Hi all,

I have two workbooks, Book1 and 2, called 73.xls and 3.xls. Both are opened
before the code below.

73.xls is active when the code reaches this point, and as shown below, the
3rd code line shown is where it switches to 3.xls.

But when it gets to line 9 -- Rows(Cells(n, n).Value).Copy -- it crashes.
I've tried changing the code a few ways but cant get it working. Does anyone
have any ideas?

Sheets("Sheet1").Select

n = Range("A1").Value

Windows("3.xls").Activate

With ThisWorkbook.Sheets("Sheet1")
.Unprotect "1234"
End With

Sheets("Sheet1").Select
n = n + 1
Rows(Cells(n, n).Value).Copy

With ThisWorkbook.Sheets("Sheet1")
.Protect "1234"
End With

Windows("73.xls").Activate

With ThisWorkbook.Sheets("DataIn").Rows("3:3")
.PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False

End With