Put information (char and numb) in and out of an existing Excel Sheet

Hi Eddie VB and others,



You have send me some usefull information, but I still have some questions.



How can I put information (characters and numbers) in an axisting Excel sheet.

!!VB must not create a new Excel workbook!!



And how can I get information from an existing Excel sheet and put it in a VB program.



Can someone help me please...



Thanks a lot, David.






Comments

  • Try this code, it works both ways...



    You have to add "Microsoft Excel 9.0(Or what ever version you have) Object Library" in your references.



    Public Function TestExcel() as String

    Dim strExcelFile, strValue, strSheet as String

    Dim intRow, intCol as Integer



    ' --->

    'What ever code you need to add

    ' <---<br>


    Excel.Workbooks.Open strExcelFile, , True

    Excel.Sheets.Select (strSheet)

    Excel.Cells(intRow , intCol) = strValue

    Excel.Workbooks(strSheet).Close



    End Function



    Best regards Kalle


  • I still have a question about this solution.

    Where do I have to fill the data that I want to put in my Excel-sheet and where do I have to put the name of the Excel-sheet that I want to open. Can you give an example, i.e. when I want to put the number 22 in cell B9 in the Excel-sheet book1.xls



    Can you please help me again....



    Thanks a lot, David.













    : Try this code, it works both ways...

    :

    : You have to add "Microsoft Excel 9.0(Or what ever version you have) Object Library" in your references.

    :

    : Public Function TestExcel() as String

    : Dim strExcelFile, strValue, strSheet as String

    : Dim intRow, intCol as Integer

    :

    : ' --->

    : 'What ever code you need to add

    : ' <---<br>
    :

    : Excel.Workbooks.Open strExcelFile, , True

    : Excel.Sheets.Select (strSheet)

    : Excel.Cells(intRow , intCol) = strValue

    : Excel.Workbooks(strSheet).Close

    :

    : End Function

    :

    : Best regards Kalle

    :






Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories