Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default PasteSpecial method of Range class failed

Assuming the user did select the range with cntl-c first, but wanted to put
the paste somewhere of their own choosing, not neccessarily in C13? That is
where the issue is. Thanks for thinking about it.

Frank

wrote in message
ups.com...
On Aug 26, 12:07 pm, "Frank Hayes" wrote:
I am trying to write what I thought would be a very simple macro, but I
am
encountering a "PasteSpecial method of range class failed" runtime error.
The intent of the macro is to take a range that has previously been
selected
by the user and to copy the values and format of the range into a new
cell(s).

I have commented out the original select.copy (as this is the action the
user now takes). Any ideas?

Sub PasteFormatValues()
'
' Range("C10:F10").Select
' Selection.Copy
' Range("C13").Select

Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=
_
False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:=
_
False, Transpose:=False
Application.CutCopyMode = False

End Sub

Thank you,

Frank Hayes


By commenting out those lines Excel doesn't know where to paste the
data or, if the user has not added something to the clipboard via Ctrl-
C, what to paste. It's not ideal but why not ask the user to select a
range and then run the code as below?

Sub PasteFormatValues()

Selection.Copy
Range("C13").PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= False, Transpose:=False
Range("C13").PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
' You may be able to combine the two lines above into the one
below
' Range("C13").PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

Application.CutCopyMode = False

End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default PasteSpecial method of Range class failed

I am trying to write what I thought would be a very simple macro, but I am
encountering a "PasteSpecial method of range class failed" runtime error.
The intent of the macro is to take a range that has previously been selected
by the user and to copy the values and format of the range into a new
cell(s).

I have commented out the original select.copy (as this is the action the
user now takes). Any ideas?

Sub PasteFormatValues()
'
' Range("C10:F10").Select
' Selection.Copy
' Range("C13").Select

Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Application.CutCopyMode = False

End Sub


Thank you,

Frank Hayes


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default PasteSpecial method of Range class failed

On Aug 26, 12:07 pm, "Frank Hayes" wrote:
I am trying to write what I thought would be a very simple macro, but I am
encountering a "PasteSpecial method of range class failed" runtime error.
The intent of the macro is to take a range that has previously been selected
by the user and to copy the values and format of the range into a new
cell(s).

I have commented out the original select.copy (as this is the action the
user now takes). Any ideas?

Sub PasteFormatValues()
'
' Range("C10:F10").Select
' Selection.Copy
' Range("C13").Select

Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Application.CutCopyMode = False

End Sub

Thank you,

Frank Hayes


By commenting out those lines Excel doesn't know where to paste the
data or, if the user has not added something to the clipboard via Ctrl-
C, what to paste. It's not ideal but why not ask the user to select a
range and then run the code as below?

Sub PasteFormatValues()

Selection.Copy
Range("C13").PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= False, Transpose:=False
Range("C13").PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
' You may be able to combine the two lines above into the one
below
' Range("C13").PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

Application.CutCopyMode = False

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default PasteSpecial method of Range class failed

The code works fine for me. Are you sure the user is doing the 3 steps
properly before running the code?

Mike F
"Frank Hayes" wrote in message
...
I am trying to write what I thought would be a very simple macro, but I am
encountering a "PasteSpecial method of range class failed" runtime error.
The intent of the macro is to take a range that has previously been
selected by the user and to copy the values and format of the range into a
new cell(s).

I have commented out the original select.copy (as this is the action the
user now takes). Any ideas?

Sub PasteFormatValues()
'
' Range("C10:F10").Select
' Selection.Copy
' Range("C13").Select

Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

End Sub


Thank you,

Frank Hayes




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default PasteSpecial method of Range class failed

Your problem is due to the paste range being inside the copy range. VBA is
not allowing you to select the paste range when one of the cells is already
selected in the copy range. The solution is not to select the source range,
just copy like the code below. Notice I have one line commented out

Sub PasteFormatValues()
'
Range("C10:F10").Copy
' Selection.Copy
Range("C13").Select

Selection.PasteSpecial Paste:=xlValues, _
Operation:=xlNone, SkipBlanks:=False, _
Transpose:=False

Selection.PasteSpecial Paste:=xlFormats, _
Operation:=xlNone, SkipBlanks:=False, _
Transpose:=False
Application.CutCopyMode = False

End Sub


" wrote:

On Aug 26, 12:07 pm, "Frank Hayes" wrote:
I am trying to write what I thought would be a very simple macro, but I am
encountering a "PasteSpecial method of range class failed" runtime error.
The intent of the macro is to take a range that has previously been selected
by the user and to copy the values and format of the range into a new
cell(s).

I have commented out the original select.copy (as this is the action the
user now takes). Any ideas?

Sub PasteFormatValues()
'
' Range("C10:F10").Select
' Selection.Copy
' Range("C13").Select

Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Application.CutCopyMode = False

End Sub

Thank you,

Frank Hayes


By commenting out those lines Excel doesn't know where to paste the
data or, if the user has not added something to the clipboard via Ctrl-
C, what to paste. It's not ideal but why not ask the user to select a
range and then run the code as below?

Sub PasteFormatValues()

Selection.Copy
Range("C13").PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= False, Transpose:=False
Range("C13").PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
' You may be able to combine the two lines above into the one
below
' Range("C13").PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

Application.CutCopyMode = False

End Sub




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default PasteSpecial method of Range class failed

I am having the same problem. A macro I used to use (with XL2000, I
think) is not currently working with XL2003 (11.8146.8132 SP2) on my
WinXP SP2 machine.

Sub PasteValues_SkipBlanks()
' Macro edited 9/2002 by DH
Selection.PasteSpecial Paste:=xlValues, SkipBlanks:=True
End Sub

I tried a reboot, but it still generates the "PasteSpecial method of
range class failed" error. How frustrating!

- David



On Aug 25, 12:38 pm, "Frank Hayes" wrote:
Assuming the user did select the range with cntl-c first, but wanted to put
the paste somewhere of their own choosing, not neccessarily in C13? That is
where the issue is. Thanks for thinking about it.

Frank

wrote in message

ups.com...

On Aug 26, 12:07 pm, "Frank Hayes" wrote:
I am trying to write what I thought would be a very simple macro, but I
am
encountering a "PasteSpecial method of range class failed" runtime error.
The intent of the macro is to take a range that has previously been
selected
by the user and to copy the values and format of the range into a new
cell(s).


I have commented out the original select.copy (as this is the action the
user now takes). Any ideas?


Sub PasteFormatValues()
'
' Range("C10:F10").Select
' Selection.Copy
' Range("C13").Select


Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:=
_
False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:=
_
False, Transpose:=False
Application.CutCopyMode = False


End Sub


Thank you,


Frank Hayes


By commenting out those lines Excel doesn't know where to paste the
data or, if the user has not added something to the clipboard via Ctrl-
C, what to paste. It's not ideal but why not ask the user to select a
range and then run the code as below?


Sub PasteFormatValues()


Selection.Copy
Range("C13").PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= False, Transpose:=False
Range("C13").PasteSpecial Paste:=xlFormats, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
' You may be able to combine the two lines above into the one
below
' Range("C13").PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:=xlNone, SkipBlanks:=False, Transpose:=False


Application.CutCopyMode = False


End Sub



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default PasteSpecial method of Range class failed

I am using XL 2003 and I am having a similar problem. I run this
block of code to paste values from one sheet to another. I have used
code like this for years, and all the sudden, this starts breaking.
And, here is the fun part, I run the code and it works sometimes. I
never know when it will fail. It is so random. This is killing me.

I have tried to create objRange object and assign them and it works
sometime and fails others.
Also, I tried adding the line Worksheets("Daily Dashboard").Range
("C72").Select before the first PasteSpecial as to select the cell
first before pasting. Then I get the "Select method of range class
failed"

PLEASE HELP!!! Thanks in Advance!

Here is my code:
Private Sub cmdGetData_Click()

[Result1].Value = ""
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Worksheets("Calculation Sheet").Range("A39:A62").Copy
Worksheets("Daily Dashboard").Range("C72").PasteSpecial
xlPasteValues
Worksheets("Calculation Sheet").Range("C39:C62").Copy
Worksheets("Daily Dashboard").Range("E72").PasteSpecial
xlPasteValues

[Result1].Value = "Complete"
Application.Calculation = xlCalculationAutomatic
Sheets("Control Panel").Select
Application.ScreenUpdating = True

End Sub

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
PasteSpecial Method of Range Class Failed Error a Different Versio SteveC Excel Programming 10 February 16th 07 03:08 PM
PasteSpecial Method of Range Class Failed Error Brian C Excel Programming 5 March 30th 06 08:01 PM
runtime error 1004 pastespecial method of range class failed dreamz[_29_] Excel Programming 5 February 3rd 06 02:57 PM
PasteSpecial method of Range class failed windsor Excel Programming 6 October 6th 05 10:16 PM
Run-time error '1004' PasteSpecial Method of Range Class Failed Kevin G[_2_] Excel Programming 1 February 3rd 04 05:01 AM


All times are GMT +1. The time now is 09:46 AM.

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

About Us

"It's about Microsoft Excel"