Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Add name to excel workbook tab using VB.NET 2005

I need to be able to pass a worksheet in a workbook into different functions. It will all live one workbook. There will be no other work book. I am also trying to loop though the column heading from a SQL dataset using the offset method from the range class. I have passed the workbook and the worksheet.

Dim rng As Excel.Range = CType(activeSheet.Cells(1, 1), Excel.Range)

With objBook
Dim columnName1 As String
columnCount = ds.Tables(0).Columns.Count
For x = 0 To columnCount - 1 'populates column heading by incremanting though the letter heading
columnName1 = ds.Tables(0).Columns.Item(x).ColumnName
rng.Offset(r, c).Value = columnName1

r += 1
Next
End With
[806 byte] By [Alisa] at [2007-11-11 7:53:27]