help with macro code

  • Thread starter Thread starter Sarah
  • Start date Start date
S

Sarah

I am trying to copy a range of cells to another
worksheet .... and then move to the next column
Please help with code - I'm getting a Runtime error 1004
thanks


Sub Macro2()
'
' Macro2 Macro
' Macro recorded 08/10/2003 by SARAH RANSOME
'
' Keyboard Shortcut: Ctrl+f
'
Sheet2.Range("E2:E56").End(xlToRight).Offset(0,
1).Value _
= Sheet1.Range("G2:G56").Value
 
When you do xltoright the over 1 (.offset(0,1)) are you sure you're still on the
worksheet--you didn't go all the way over to column IV did you?

Another possibility: Are you using xl97 and running this from a commandbutton
from the controls toolbar placed on the worksheet?

If yes, try changing its .takefocusonclick property to false. (If it's a
control from that toolbar that doesn't have that property, try adding:

activecell.activate

to the top of your routing (a bug fixed in xl2k).

==
But a second problem. When I ran your code, I got one cell populated.

This line:
Sheet2.Range("E2:E56").End(xlToRight).Offset(0, 1)
did the same exact thing as this:
Sheet2.Range("E2").End(xlToRight).Offset(0, 1)
(Just row 2 was populated.

Maybe:

Sheet2.Range("E2").End(xlToRight).Offset(0, 1).Resize(55).Value _
= Sheet1.Range("G2:G56").Value

To get all 55 rows.
 
Back
Top