Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 149,928 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,832 people online right now. Registration is fast and FREE... Join Now!




Transpose with PasteSpecial using Excel module of VB 2005

 
Reply to this topicStart new topic

Transpose with PasteSpecial using Excel module of VB 2005

scalt
18 Dec, 2007 - 05:27 PM
Post #1

D.I.C Head
Group Icon

Joined: 22 Nov, 2007
Posts: 114



Thanked: 3 times
Dream Kudos: 25
My Contributions
Hi

I want to be able to copy 3 cells of one row in one Excel file, and paste them into 3 cells of one column in another Excel file. I am using the Transpose property of the PasteSpecial command as part of the Excel module, but am getting errors whenever I set the 'Transpose' property to 'True'. I am not 100% sure how correct my code is as I wasn't sure how to tell it to transpose the selection. I looked on the web and the most common answer to questions about transposing cells simply to add 'false, true' inside the paste special brackets (false for skipblanks, true for transpose).

Here is my code:
CODE

xlSht = xlApp.Worksheets("Paddock")
xlRng = xlSht.Range(xlSht.Cells(2, 2), xlSht.Cells(2, 5))
xlOutRng = xlOutSht.Cells(3, 4)

xlRng.Copy()
xlOutRng.PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll, Microsoft.Office.Interop.Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, False, True)


Note: I get the error "PasteSpecial method of Range class failed" on the last line.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 03:09PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month