ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Another runtime 1004 error (https://www.excelbanter.com/excel-programming/404456-another-runtime-1004-error.html)

Zilla[_4_]

Another runtime 1004 error
 
I get error 1004 "Unable to get the pastespecial property of the range
class". Thanks again!

' Generic subroutine to transpose a range of cells
' from source to destination
' *** WARNING ***
' This should be used when ranges match, i.e, source and
' destination ranges have the same number of cells
Sub copyRange(sRange As Range, dRange As Range)
If (sRange.Cells.Count = dRange.Cells.Count) Then
sRange.Copy dRange.PasteSpecial(Paste:=xlAll, _
Operation:=xlNone, _
SkipBlanks:=True, _
Transpose:=True)
Application.CutCopyMode = False
End If
End Sub

Jim Thomlinson

Another runtime 1004 error
 
Try this...

Sub copyRange(sRange As Range, dRange As Range)
If (sRange.Cells.Count = dRange.Cells.Count) Then
sRange.Copy
dRange.PasteSpecial(Paste:=xlAll, _
Operation:=xlNone, _
SkipBlanks:=True, _
Transpose:=True)
Application.CutCopyMode = False
End If
End Sub
--
HTH...

Jim Thomlinson


"Zilla" wrote:

I get error 1004 "Unable to get the pastespecial property of the range
class". Thanks again!

' Generic subroutine to transpose a range of cells
' from source to destination
' *** WARNING ***
' This should be used when ranges match, i.e, source and
' destination ranges have the same number of cells
Sub copyRange(sRange As Range, dRange As Range)
If (sRange.Cells.Count = dRange.Cells.Count) Then
sRange.Copy dRange.PasteSpecial(Paste:=xlAll, _
Operation:=xlNone, _
SkipBlanks:=True, _
Transpose:=True)
Application.CutCopyMode = False
End If
End Sub


Zilla[_4_]

Another runtime 1004 error
 
Ah, syntax error. I did this and it worked!
Range.Copy
dRange.PasteSpecial Paste:=xlAll, _
Operation:=xlNone, _
SkipBlanks:=True, _
Transpose:=True)


On Jan 17, 11:42*am, Zilla wrote:
I get error 1004 "Unable to get the pastespecial property of the range
class". Thanks again!

' Generic subroutine to transpose a range of cells
' from source to destination
' *** WARNING ***
' This should be used when ranges match, i.e, source and
' destination ranges have the same number of cells
Sub copyRange(sRange As Range, dRange As Range)
* * If (sRange.Cells.Count = dRange.Cells.Count) Then
* * * * sRange.Copy dRange.PasteSpecial(Paste:=xlAll, _
* * * * * * * * * * * * * * * * * * * * Operation:=xlNone, _
* * * * * * * * * * * * * * * * * * * * SkipBlanks:=True, _
* * * * * * * * * * * * * * * * * * * * Transpose:=True)
* * * * Application.CutCopyMode = False
* * End If
End Sub




All times are GMT +1. The time now is 08:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com