Your example still has unqualified references.
Note the dot before Cells.
Protecting the sheet empties the clipboard.
Protect it after pasting ...
'--
n = Sheets("Calculations").Range("A12").Value
With Workbooks("3.xls").Sheets("Sheet1")
.Unprotect "1234"
n = n + 1
.Rows(.Cells(n, n).Value).Copy
ThisWorkbook.Sheets("DataIn").Rows("3:3").PasteSpe cial _
Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
.Protect "1234"
End With
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)
"dim"
wrote in message
Hi again!
My name is Diarmaid and I'm from Ireland. :-)
Thanks for the advice so far. I tried those changes but have the same error.
Its Error 1004 - Application Defined or Object Defined Error.
I'm using Excel 2002, and the code is in 73.xls which is my user interface
workbook. 3.xls is just data storage, the data in which is saved in rows.
I simply want to be able to copy a complete row, from my data workbook, into
the user workbook. The only catch is that the row is specified by the number
in a cell in 73.xls, so its not always the same row being copied. The reason
for this then, is that the cell number is generated by a listbox where the
user chooses which employee's data they want to see.
Surely people often copy rows from one workbook to another using the number
in a cell?
Sheets("Calculations").Select
n = Range("A12").Value
Workbooks("3.xls").Activate
With ActiveWorkbook.Sheets("Sheet1")
.Unprotect "1234"
End With
Sheets("Sheet1").Select
n = n + 1
Rows(Cells(n, n).Value).Copy
With ActiveWorkbook.Sheets("Sheet1")
.Protect "1234"
End With
Workbooks("73.xls").Activate
With ThisWorkbook.Sheets("DataIn").Rows("3:3")
.PasteSpecial _
Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
End With
I changed one sheet around thats why it says 'calculations' now. The error
is the same.