insert row to Excel spreadseet from VB

  • Thread starter Thread starter Alex
  • Start date Start date
You must use Automation to open the EXCEL file and to write to the specific
"row" of cells.

This is some generic code:

Dim xlsApp As Object, xlsWB As Object, xlsWS As Object, xlsRng As Object
Set xlsApp = CreateObject("Excel.Application")
Set xlsWB = xlsApp.Workbooks.Open("C:\FolderName\FileName.xls", , True)
Set xlsWS = xlsWB.Worksheets("WorkSheetName")
Set xlsRng = xlsWS.Range("A1")
xlsRng.Value = VariableName
Set xlsRng = Nothing
Set xlsWS = Nothing
xlsWB.Close True
Set xlsWB = Nothing
xlsApp.Quit
Set xlsApp = Nothing
 
Thanks, Ken.
-----Original Message-----
You must use Automation to open the EXCEL file and to write to the specific
"row" of cells.

This is some generic code:

Dim xlsApp As Object, xlsWB As Object, xlsWS As Object, xlsRng As Object
Set xlsApp = CreateObject("Excel.Application")
Set xlsWB = xlsApp.Workbooks.Open
("C:\FolderName\FileName.xls", , True)
 
Back
Top