Anand Bohra

Anand Bohra

  • NA
  • 233
  • 0

Select Sheet in VB dot net

May 26 2010 10:51 AM

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
 

Answers (3)