Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
why don't buttons work?
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! . |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
For that the buttons do not work of reordering, in the panel of s. | Excel Discussion (Misc queries) | |||
rigth click and some buttons from toolbar does not work | Excel Discussion (Misc queries) | |||
New Buttons dont work after I put them in the toolbar | New Users to Excel | |||
buttons dont seem to work after I put them into the toolbar | Excel Discussion (Misc queries) | |||
can you put radio buttons into an excel work sheet? and how? | Excel Worksheet Functions |