View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
steve steve is offline
external usenet poster
 
Posts: 576
Default thanks Mike!

Just to add. On the destination - you only need to specify a single cell.
This avoids the problem of matching areas.

Sheets("SHIFTS").Range("A20:C28").Value = _
Sheets("A3").Range("D1").Value

steve

"NFI" wrote in message
...
Thanks for that, it's working a treat and doesn't copy the
formatting either, meaning I can do away with the unmerge
cells code later on.
-----Original Message-----
Try something like this instead:
Sheets("SHIFTS").Range("A20:C28").Value = Sheets
("A3").Range("D1:F9").Value

-----Original Message-----
Hello there

I recorded a macro to copy cells from one sheet and put
them onto another sheet.
I then used a button on the destination sheet to call

the
macro. All was working ok, but the macro code was very
long so I removed unecessary bits and got it down from 6
lines to 1.
This one line of code works when I step through the

macro,
but produces an error when I call it from the button.

The original code was this, as recorded by the macro and
which worked when called by the button on the sheet.
Sheets("A3").Select
Range("D1:F9").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("SHIFTS").Select
Range("A20").Select
ActiveSheet.Paste

I then reduced this to one line which works when I step
through the code, but produces an error message "Copy
method of Range Class failed" when called by the button.

Sheets("A3").Range("D1:F9").Copy Sheets("SHIFTS").Range
("A20")

I'm running exel 97

Any comments much appreciated!
.

.