xluser2007
02-23-2008, 03:46 AM
Hi All,
I am writing a main macro that involves a lot of copying and value pasting output into various cells.
In order to make the main macro read easier, I've just tried to create another macro to carry out the copy-value paste routine as follows:
Sub Copypaste(x As Range, y As Range)
x.Copy
y.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
I then tried to test this as follows:
Sub Testcopypaste()
Call Copypaste("A12", "X12")
End Sub
Sub Testcopypaste kept running into a type mismatch error and highlighted "A12" when debugging.
Any ideas how to make this work, should Copypaste be defned as a UDF? If so, how do I go about doing this?
Any VBAGuru guidance is appreciated.
I am writing a main macro that involves a lot of copying and value pasting output into various cells.
In order to make the main macro read easier, I've just tried to create another macro to carry out the copy-value paste routine as follows:
Sub Copypaste(x As Range, y As Range)
x.Copy
y.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
I then tried to test this as follows:
Sub Testcopypaste()
Call Copypaste("A12", "X12")
End Sub
Sub Testcopypaste kept running into a type mismatch error and highlighted "A12" when debugging.
Any ideas how to make this work, should Copypaste be defned as a UDF? If so, how do I go about doing this?
Any VBAGuru guidance is appreciated.