Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Oct 2005
    Location
    Solon, Ohio, USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Write to Excel from VB (Excel 97 SR-2)

    Need a "Kick Start" on how to write to Excel from the Excel's embedded Visual Basic Editor. I have sent and received data with the added control, MSCOMM1, to a remote device through Comm Port 1. I need to populate the spread sheet with incoming data.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Write to Excel from VB (Excel 97 SR-2)

    Welcome to Woody's Lounge!

    Assuming that you have the data in a variable (which might be an array), you can use code like this:

    To cell B37 in the active worksheet:

    Range("B37") = MyVar

    To cell B37 in worksheet Sheet5 in the active workbook:

    Worksheets("Sheet5").Range("B37") = MyVar

    To cell B37 in worksheet Sheet5 in the open workbook MyBook.xls:

    Workbooks("MyBook.xls").Worksheets("Sheet5").Range ("B37") = MyVar

    Instead of Range("B37") you can also use Cells(37, 2) (the first number is the row number, the second the column number).

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Write to Excel from VB (Excel 97 SR-2)

    See if any of these help.

    http://www.zaber.com/zaber/support.asp
    http://www.msc-lims.com/lims/diybalance.html
    http://www.yes-tele.com/mscomm.html
    http://www.developerfusion.co.uk/forums/topic-26620

    See Hans post for information to get a value into a cell. A more complex but more efficient way is place and hold the values into an array and then paste the array into a worksheet.
    -John ... I float in liquid gardens
    UTC -7ąDS

  4. #4
    New Lounger
    Join Date
    Oct 2005
    Location
    Solon, Ohio, USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Write to Excel from VB (Excel 97 SR-2)

    Thank You Very Much!!!
    Regards - Jerry

  5. #5
    New Lounger
    Join Date
    Oct 2005
    Location
    Solon, Ohio, USA
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Write to Excel from VB (Excel 97 SR-2)

    Thank You Very Much!!!
    Regards - Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •