Hi
I am doing a project to read the output of an instrument and store in excel sheet.
I have succesfully read the data thru mscomm1 and am able to show it in a text box.
The data from serial it read from 3 second in 3 second using a Timer.
In the textbox is new data from 3 second in 3 second.

I dont know how to store this data in excel sheet to different row for each registration .


pls help me in this regard.

hi jabbaro, try this hope it helps..

make sure to reference the microsoft excel library in vb.. go to project->references find ms excel lib

you'll need 2 command button(start and stop), a timer and a textbox

put this code in a module

Public xlap As Excel.Application
Public xlbook As Excel.Workbook
Public xlsheet As Excel.Worksheet

and add this code to the button, timer and the form

Public i As Integer


Private Sub Form_Load()

Set xlap = New Excel.Application   'Create a new instance of Excel
Set xlbook = xlap.Workbooks.Add    'Add a new workbook
Set xlsheet = xlbook.Worksheets(1) 'Work with the first worksheet

Timer1.Interval = 2000             'set the timer to capture every 2 seconds
Timer1.Enabled = False

End Sub

Private Sub Start_Click()

Timer1.Enabled = True            'start timer and start getting data

End Sub

Private Sub Stop_and_Save_Click()

Timer1.Enabled = False
xlbook.SaveAs "C:\result1.xls" 'Save the Workbook (change to your desired filename)
xlbook.Close
xlap.Quit                      'Close  Excel
Set xlap = Nothing

Unload Me

End Sub

Private Sub Timer1_Timer()

xlsheet.Cells(i + 1, 1).Value = Text1.Text 'change to the textbox in your form (ex. text2.text)
i = i + 1                                  'increment the row

End Sub

Hello! I am working on a programme transferring data from VB6 to excel. Unfortunately this is supposed to be Excel 2007. Is there any possibility to put data into 2007's worksheets? A solution given in this topic seems not to work...
Best regards, Jan

This question has already been answered. Start a new discussion instead.