Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Run-time error "1004" Select method of range class failed

Hello,

I'm having a little trouble with a command button I've been playing around
with, all I want it to do is copy text onto another sheet to specific
locations using the destination formatting. I came up with this macro:

Macro1 Macro
' Macro recorded 06/03/2007 by
'

'
ActiveWindow.SmallScroll ToRight:=-2
Range("A3").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A5").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Sheet1").Select
Range("F3").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("A7").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub


which works fine, but when I add this code to a command button object in the
sheet I get an error. "Run-time error "1004" Select method of range class
failed"

The error is with these commands...

Sheets("Sheet2").Select
Range("A5").Select

Can anyone help me out?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Run-time error "1004" Select method of range class failed

Macro CopyCellstoSheet2
sheets("sheet1").Range("A3").Copy Sheets("Sheet2").Range("A5")
Sheets("Sheet1").Range("F3").Copy Sheets("Sheet2").Range("A7")
End Sub

or , Notice the placement of the . before range

with sheets("sheet1")
.Range("A3").Copy Sheets("Sheet2").Range("A5")
.Range("F3").Copy Sheets("Sheet2").Range("A7")
end with


--
Don Guillett
SalesAid Software

"Tallan" wrote in message
...
Hello,

I'm having a little trouble with a command button I've been playing around
with, all I want it to do is copy text onto another sheet to specific
locations using the destination formatting. I came up with this macro:

Macro1 Macro
' Macro recorded 06/03/2007 by
'

'
ActiveWindow.SmallScroll ToRight:=-2
Range("A3").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A5").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Sheet1").Select
Range("F3").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("A7").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub


which works fine, but when I add this code to a command button object in
the
sheet I get an error. "Run-time error "1004" Select method of range class
failed"

The error is with these commands...

Sheets("Sheet2").Select
Range("A5").Select

Can anyone help me out?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 857
Default Run-time error "1004" Select method of range class failed

In order to make your code work, you need to replace lines like this

Sheets("Sheet2").Select

With this

Sheets("Sheet2").Activate

But you don't really need to activate sheets and/or select cells when
copying. Per your description, all you want to do is copy text onto another
sheet to specific locations using the destination formatting. The code below
copies the formula in Sheet1!A1 to Sheet2!A1 and retains the format in
Sheet2!A1.

Sheets("Sheet2").Range("A1").Formula = Sheets("Sheet1").Range("A1").Formula



"Tallan" wrote:

Hello,

I'm having a little trouble with a command button I've been playing around
with, all I want it to do is copy text onto another sheet to specific
locations using the destination formatting. I came up with this macro:

Macro1 Macro
' Macro recorded 06/03/2007 by
'

'
ActiveWindow.SmallScroll ToRight:=-2
Range("A3").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A5").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Sheet1").Select
Range("F3").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("A7").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub


which works fine, but when I add this code to a command button object in the
sheet I get an error. "Run-time error "1004" Select method of range class
failed"

The error is with these commands...

Sheets("Sheet2").Select
Range("A5").Select

Can anyone help me out?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Run-time error "1004" Select method of range class failed

Do you have a "Sheet2" ?

Maybe misspelled or has a space in the name?

Works for me without error if I have a Sheet2.


Gord Dibben MS Excel MVP

On Wed, 7 Mar 2007 05:04:10 -0800, Tallan
wrote:

Hello,

I'm having a little trouble with a command button I've been playing around
with, all I want it to do is copy text onto another sheet to specific
locations using the destination formatting. I came up with this macro:

Macro1 Macro
' Macro recorded 06/03/2007 by
'

'
ActiveWindow.SmallScroll ToRight:=-2
Range("A3").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A5").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Sheet1").Select
Range("F3").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Range("A7").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub


which works fine, but when I add this code to a command button object in the
sheet I get an error. "Run-time error "1004" Select method of range class
failed"

The error is with these commands...

Sheets("Sheet2").Select
Range("A5").Select

Can anyone help me out?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Method 'MacroOptions' of object'_Application' failed Runtime Error 1004 EagleOne Excel Discussion (Misc queries) 1 October 22nd 14 05:49 PM
Charts.Add error '1004' Method 'Add' of object 'Sheets' failed Corey Charts and Charting in Excel 1 December 28th 06 02:15 PM
Error: method 'select' of object_worksheet' failed Carl Excel Discussion (Misc queries) 4 September 9th 06 08:52 PM
Dynamic chart generation: Run time Error '1004: Method 'Cells' of object'_Global' fai Ajay_N Charts and Charting in Excel 1 August 15th 06 03:54 AM
runtime error 1004 method range of object '_global failed valdesd Excel Discussion (Misc queries) 2 October 6th 05 07:26 PM


All times are GMT +1. The time now is 11:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"