VB.NET - Vb.Net - Copying cells from from worksheet to another

Asked By C P on 08-Apr-13 09:41 AM
Hi,

This I think is a simple solution. Just that I have spent too long trying to do it.

I have a worksheet named, "ABCD" and have headings from A1....D1 e.g. forename, surname, department, age

I want to copy and paste this line into my other worksheet "EFGH" at the same place.

How is this done?
Sum Green replied to C P on 08-Apr-13 10:58 PM
Hello, here is my code.

'Load Workbook
Dim book As New Workbook()
book.LoadFromFile("Test.xlsx")
 
'Copy Text from ABCD Worksheet to EFGH Worksheet
book.Worksheets("ABCD").Range("A1:D1").Copy(book.Worksheets("EFGH").Range("A1:D1"))

My code is based a VB.NET Word library introduced here: http://sourceforge.net/projects/spiredocfornet/, not Microsoft.Office.Interop.
C P replied to Sum Green on 09-Apr-13 09:13 AM
Thanks for this sample code.

Now works a treat.