Hi,
I am creating a excel file using VB Dot Net to fetch data from SQL.
It works well & code is 100% complete
the only problem is how to give reference to excel sheet using its name property rather than displayed name
like I am using Globals.Thisworkbook.Sheets("Database")
now my requirement is what if user changed the sheet name from Database to say DB or whatever. My code fails
I tried lot to give reference to sheet number programatically but all in vain
In VBA I used to give reference like Sheet1.select instead of Sheets("Database").select so that my code run irrespective of sheet name.
Kindly suggest me the same way in VB DOT NET
I tried Globals.thisworkbook.sheets(1)
Globals.thisworkbook.worksheets.item(1)
but all fails even if user change sheet positions.
Pl . Pl. help me its urgent
Loading
PJ MartinsPosted May 27, 2010, 9:12 AM
Anand BohraPosted May 27, 2010, 2:48 AM
the equivalent VB code is
Globals.ThisWorkbook.Worksheets.Item(1)
but the same is populated based on total sheets in workbook counting from left to right
so whatever sheet be in first positions will be taken irrespective of sheet name or its program name
I want to select particular sheet based on its named property rather than caption
like in VBA we use Sheet1.select instead of Sheets("ABC").select
PJ MartinsPosted May 26, 2010, 9:28 PM