View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano Vergel Adriano is offline
external usenet poster
 
Posts: 857
Default Can't select worksheet

Because the code is in Sheet2, Cells(3,1) would refer to A3 in Sheet2, even
if Sheet1 was the activesheet. If it were in a code module, Cells(3,1) would
have referred to A3 in the activesheet. To be safe, always qualify your
ranges.

"bw" wrote:

The following code is called from Sheet2:

1. Worksheets("Sheet1").Unprotect
2. Worksheets("Sheet1").Activate
3. Cells(3, 1).Copy 'THIS CELL IS COPIED FROM SHEET2....and is WRONG
4. Worksheets("Sheet1").Cells(I, 1).Copy 'THIS CELL IS COPIED FROM
SHEET1....and is CORRECT

Why doesn't line 3 do the copy from Sheet1 as I had intended?

Thanks,
Bernie