Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
This I think is a simple solution. Just that I have spent too long trying to do it.

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

I want to copy and paste this line into my other worksheet "SheetB" at the same place.
 
How is this done?
Posted 8-Apr-13 7:31am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Maciej Los at 8-Apr-13 14:11pm
   
This is for VBA, not for VB.NET ;(
Kenneth Haugland at 8-Apr-13 14:52pm
   
I know, that is true, but they are easily converted. :-)
Maciej Los at 8-Apr-13 14:57pm
   
I know, i expected that you reply me this way ;)
Kenneth Haugland at 8-Apr-13 15:12pm
   
Google is rather predictable, I know :laugh:
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Using late binding Wink | ;)
        Dim oExc As Object = Nothing, oWbk As Object = Nothing
        Dim oSrcWsh As Object = Nothing, oDstWsh As Object = Nothing
 
        Try
            oExc = CreateObject("Excel.Applictaion")
            oWbk = oExc.Workbooks.Open("FullPathToWorkbook.xls")
 
            oSrcWsh = oWbk.WorkSheets("Sheet1")
            oDstWsh = oWbk.WorkSheets("Sheet2")
 
            oSrcWsh.Range("A1:D1").Copy(oDstWsh.Range("A1"))
            oWbk.Save()
 
        Catch ex As Exception
            Console.WriteLine(ex.Message)
 
        Finally
            oSrcWsh = Nothing
            oDstWsh = Nothing
            oWbk.Close(SaveChanges:=False)
            oWbk = Nothing
            oExc.Quit()
            oExc = Nothing
        End Try
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,327
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,920


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 8 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100