Range object does not support paste method

M

MichaelDavid

Greetings! Does anyone know why

Range("AJ8").Select
ActiveSheet.Paste

works, but

Range("AJ8").Paste

gives the error message:

"Run-time error '438':
Object Doesn't support this property or method!

and is there anyway of accomplishing this with one instruction rather than 2
instructions. Thanks in advance for your help and suggestions.

--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick
 
M

marcus

Hi Michael

Either of these in one line gets it done.

Range("AJ8").value = Range("AJ8").value

Or

Range("AJ8").copy Range("AJ8")

You decide.

Take it easy

Marcus
 
R

Rob van Gelder

Marcus asnwered it, but I'll also add that it's good practise to avoid using the clipboard, unless absolutely needed.
In my view, the clipboard belongs to the user, not the macro.
 
J

Jacob Skaria

You can have the copy and paste in a single line. without selecting the copy
range.The below code copies range A1:B10 to Range D1 of the same sheet.

Range("A1:B10").Copy Range("D1")

'Copies the range from Sheet1 to Sheet2
Sheets("Sheet1").Range("A1:B10").Copy Sheets("Sheet2").Range("D1")
 
M

MichaelDavid

Thanks Jacob for your kind help:
The data in question is a two dimensional comma delimited file on the
Clipboard. (The data was generated by the DigitizeIt program.) The data is
numeric and is two columns by about 400 rows. With the data on the clipboard,
one could manually select Cells(8, "AJ), and then do a Ctrl+v paste, and the
data ends up properly on the worksheet. But, with the data on the clipboard,
what is the quickest/shortest/most economical way in VBA to get the data from
the clipboard onto the worksheet at Row 8, Column "AJ"?
The only way of doing this that I have found so far is:
Range("AJ8").Select
ActiveSheet.Paste

I'm hoping that this can be accomplished either by one instruction, or by
two instructions without utilizing the Select method.
Thanks once again for your kind help.

--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick
 
M

MichaelDavid

Greetings again, Jacob:
I think the book Excel 2007 VBA Programmer's Reference gives the answer.
Using the example on page 25, with the data to be pasted on the clipboard,
we can do:
ActiveSheet.Paste Destination:=Range("AJ8"). I will be trying it out later
today.
--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick
 
M

MichaelDavid

Greetings, Marcus:
I think the book Excel 2007 VBA Programmer's Reference gives the answer.
Using the example on page 25, with the data to be pasted on the clipboard,
we can do:
ActiveSheet.Paste Destination:=Range("AJ8"). I will be trying it out later
today.
--
May you have a most blessed day!

Sincerely,
--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick
 
M

MichaelDavid

Greetings:
The data I need is left on the clipboard by the DigitizeIt program. I
need to paste it to the worksheet. Fortunately, I think the book Excel 2007
VBA Programmer's Reference gives the answer.
Using the example on page 25, with the data to be pasted on the clipboard,
we can do:
ActiveSheet.Paste Destination:=Range("AJ8"). I will be trying it out later
today.
--
May you have a most blessed day!

Sincerely,
--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick
 
M

MichaelDavid

Greetings all:

I am happy to report that the instruction

ActiveSheet.Paste Destination:=Range("AJ8")

perfectly copied the clipboard to AJ8. Please note the : before the =.
--
May you have a most blessed day!

Sincerely,

Michael Fitzpatrick
 
R

RussellT

Michael, though you can find short cuts to avoid using the two commands
Range("AJ8").select
ActiveSheet.Paste

its a good idea to get use to coding this way. Later on as you code becomes
more complex you'll be much happier keeping certain routines like identify
the cell and using ActiveSheet.Paste. I learn the hard way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top