I’ve been looking for the answer to this problem for around 2 hours while working on other code. It seems like my answer should be listed in the MSDN because of its simplicity but I cant find it anywhere.

And my problem is thus: I have this VB6 program that opens up and messes with some values in an excel spreadsheet and when its done has to go to the next Sheet in the workbook (Sheet2) and do it all over again….. But I don’t know how to change its focus to Sheet2 so it can access the cells in that sheet! >.<

Using this dummy connection code what would I add to it to get it to select and show Sheet2 in the workbook?

Thanks in advance, I know my question is kinda silly. ^^;

Option Explicit
     
    Private Sub Form_Load()
      Dim AppExcel As Excel.Application
      Dim wBook As Workbook
      Dim mySheet As Worksheet
     
      Set AppExcel = New Excel.Application
      AppExcel.Application.Visible = True
      AppExcel.Workbooks.Add 'Adds a new book.
     
     
    End Sub

Boy do I feel foolish.

Sheets("Name of sheet").Select
Sheets(index).Select

Dont code while tired kids, makes you do some crazy things.

I want to know too,
Because, in my Web, Usr can upload the Excel file to write the data to Access, but now, i must confine the sheet name, just that my Programe only read sheet name a time~~~

'----------------------------------------------------------------
Set conn =server.CreateObject("ADODB.Connection") dbPath=server.MapPath(fileNa) conn.Open "driver={Microsoft Excel Driver (*.xls)};dbq=" & dbPath
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "[random$]", conn, adOpenStatic 
'-----------------------------

how to do, so i can read sheet name many time, or i can choose the sheet name;)

Boy do I feel foolish.

Sheets("Name of sheet").Select
Sheets(index).Select

Dont code while tired kids, makes you do some crazy things.

That's how you change the active sheet.

This article has been dead for over six months. Start a new discussion instead.