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.
Code: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


Reply With Quote


Bookmarks