A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Seems this is an issue in MS 2013 standard. I've checked using 2013 professional & the issue isn't there, using/doing the exact same thing.
This is just copy & paste once, no vba.
First off, it is important to note that there is no range.PasteSpecial Link:=True command. While range.Paste Link:=True is listed in the quick range.PasteSpecial right-click menu options, it is a range.Paste command; not a range.PasteSpecial command.
I don't know if this 'behaviour' has changed fom xl2010 to xl2013 but the default xl2013 behaviour for range.PasteSpecial Paste:=xlPasteAll, Transpose:=True does seem to 'remember' the behaviour of the previous range.Paste Link:=True command and try to paste links instead of values. If you explicitly use range.PasteSpecial Paste:=xlPasteValues, Transpose:=True then range.PasteSpecial 'remembers' that and subsequent range.PasteSpecial Paste:=xlPasteAll, Transpose:=True work as expected.
- Put 1 through 10 in A1:A10.
- Copy.
- Select C1 and Paste Link:=True.
- Copy C1:C10.
- Select D2 and Paste Special, Transpose (doesn't work)
- Select D3 and Paste Special, Values, Transpose (works!).
- Select D2 and Paste Special, Transpose (works!)
Code:
dim rangeSource as range, rangeC as range, rangeD as range
Set rangeSource = Range("A1:A10")
Set rangeC = Range("C1:C10")
Set rangeD = Range("D2")
rangeSource.Copy
rangeC.Paste Link:=True
'doesn't work
rangeD.PasteSpecial Paste:=xlPasteAll, Transpose:=True
'works!
rangeD.PasteSpecial Paste:=xlPasteValues, Transpose:=True
'works!
rangeD.Offset(1, 0).PasteSpecial Paste:=xlPasteAll, Transpose:=True
So the moral of the story is not to rely on default behaviour or catch-alls like Paste:=xlPasteAll since they may 'remember' something that you don't want. That goes double for coding where you have no idea what the user has previously done on the worksheet during the current editing session (see range.Find command).
I didn't use range.PasteSpecial Link:=True.
Your examples don't link. Plus you're missing a step & it's wrong here;
rangeSource.Copy
rangeSource.Select <<your example is missing this, which is why your example doesn't work.
rangeC.Paste Link:=True <<plus this is wrong. I used just Paste Link:=True, not rangeC.Paste. Which also contributes to your example not working.
I need it to link, your examples don't provide this, problem is the linking mechanism is mangling & not pasting properly when it transposes once it passes. And it's worse on a larger dataset. And clearly behaviour has changed as I've now been able to check against 2 versions of MS 2013. One works as expected, as it did in 2010, the other doesn't. Again see the image link I posted.