Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying cells from one sheet to another...

Status
Not open for further replies.

Butane

Technical User
Oct 20, 2001
8
GB
Im trying to copy cells from one sheet to another. This is the current code im using:

For x = 0 To 10
Worksheets("sheet1").Range("A2").Offset(x, 0).Value = Worksheets("sheet2").Range(currentcell.Offset(x, 0)).Value
Next x

Although every time I run it doesnt work. I cant see whats wrong with the code.
Can anyone sort it out/show me better code?

Thanks.
 
There is no object called "CurrentCell". If you want to refer to the currently active cell:

For x = 0 To 10
Worksheets("sheet1").Range("A2").Offset(x, 0).Value = ActiveCell.Offset(x, 0).Value
Next x

Before you run this code you must ensure that the currently active cell is right one e.g. worksheets(&quot;Sheet2&quot;).cells(<row>,<column>).activate

M.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top