Hi
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
any suggestion
Thanks

passing a worksheet in excel with VB.NET
Neil Kronlage - MSFT
Sorry about that...
in order from me to use the offset method, I need to access the range class... and in order to use the range class, I need the worksheet class... or at least that is the impression I have gotten... so I want to pass the worksheet that is active to this function to put in the column heading from the dataset. But I also I want to be about to call this function at anytime to add the column headings to any added sheet. I have already stored the column heading in a list.... but that is a different thing, my boss is really set on me using the offset method in this function. I am already using it in the function that places the data into the excel sheet.
this is option i tried but is a no go.
Dim xls As Excel.Worksheet = CType(objBook.Sheets(namedSheet), Excel.Worksheet)
where this is being called, i placed the name of the sheet into a string and that is what i am passing,...
Private Sub columnHeadings(ByVal ds As DataSet, ByVal namedSheet As String, ByVal objBook As Object)
HPEvju
Hi Alisa,
Could you please clarify your question From reading your posting, I am unable to understand what you wish to ask.
Thanks.