vba paste special lnks

Kaps_mr2

Well-known Member
Joined
Jul 5, 2008
Messages
1,589
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to write some VBA to paste links between workbooks. However, I am stumped:-

Code:
questionnaire.Sheets("section " & cell_txt1).Range("d" & next_blank_line).Copy
        questionnaire.Sheets("Summary").Range("c" & summary_sheet_next_blank_line).PasteSpecial , link:=True

what am I doing wrong ? thanks

Kaps
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Pasting a link is actually not a part of the PasteSpecial method; it is a part of the Paste method (I know, it is really counterintuitive. I had to record a macro to figure it out)

Try:

Code:
questionnaire.Sheets("section " & cell_txt1).Range("d" & next_blank_line).Copy
        questionnaire.Sheets("Summary").Range("c" & summary_sheet_next_blank_line).Paste , Link:=True
 
Upvote 0
thanks - tried that and it gives me "object does not support this property or method".
 
Upvote 0
Do you have "questionnaire" dimmed properly (as Workbook) and Set properly?

Also, looking a bit closer at my recorded code, we don't want the comma between paste and Link:=

Code:
questionnaire.Sheets("section " & cell_txt1).Range("d" & next_blank_line).Copy
        questionnaire.Sheets("Summary").Range("c" & summary_sheet_next_blank_line).Paste Link:=True
 
Upvote 0
I was wondering what questionaire is too...

But (if I'm not mistaken) Paste is a method of a worksheet, not a range. It may be that in this case you have to activate the sheet, select the range, then paste.

Code:
Sheet1.Cells(1, 1).Copy
With Sheet2
    .Activate
    .Cells(1, 1).Activate
    .Paste , True
End With
 
Upvote 0
I was wondering what questionaire is too...

But (if I'm not mistaken) Paste is a method of a worksheet, not a range. It may be that in this case you have to activate the sheet, select the range, then paste.

Code:
Sheet1.Cells(1, 1).Copy
With Sheet2
    .Activate
    .Cells(1, 1).Activate
    .Paste , True
End With

Range is a valid object for the paste method (according to the 2007 help files) :biggrin:
 
Upvote 0
I did discover a new method for the range object as I was looking for paste ... the parse method. Never heard of it. Just posted in the lounge to ask if anyone ever uses it. So it was a useful mistake to me. ;)
 
Upvote 0
questionnaire is defined as a workbook and is declared via set.

Have removed the "," - which I did not spot initially. Tried :-

Code:
 With questionnaire.Sheets("Summary")
        .Activate
        .Range("c" & summary_sheet_next_blank_line).Activate
        .Paste
        End With

which executes - but with a reference error in the destination cell. Putting "true" after the Paste results in an error - with excel saying thatit can't paste the data. Thanks

Regards

Kaps
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,259
Members
452,901
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top