How can I get all worksheets' names of the spreadsheet?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

As you know, a excel spreadsheet workbook can contains some worksheets and
each worksheet has its names, my problem is how to get these names. Who can
Help me ?
Any help will be very very appreciated!
 
Hi Marxi

Sub Worksheet_Names()
For Each ws In ThisWorkbook.Worksheets
Debug.Print ws.Name
Next ws
End Sub

will print the worksheet names to the Immediate Window. If you want
to print them to a worksheet itself, then maybe:

Sub Worksheet_Names()
For i = 1 to ThisWorkbook.Worksheets.Count
Cells(i,1).Value = ws.Name
Next i
End Sub

Hope this helps!

Richard
 
first and foremost, thank you for your advise!

The spreadsheet I said is a kind of COM for Csharp.NET.
It can drog on the winform to work for users as excel.
my problem is how to get the name of each worksheet using C# language.
I do not know the type of "ws" which mentioned in your answer!
Thanks again.
 
In excel's vba:
Dim ws as worksheet

first and foremost, thank you for your advise!

The spreadsheet I said is a kind of COM for Csharp.NET.
It can drog on the winform to work for users as excel.
my problem is how to get the name of each worksheet using C# language.
I do not know the type of "ws" which mentioned in your answer!
Thanks again.
 
C#can not use excel's vba and owc spreedsheet can not excute vba code.
I should use c# to solve this problem.
for example:
axSpreadsheet1.sheets.get_Names().ToString();
but "sheets" does not have the get_Names() method.
 
Maybe someone will jump in with the solution.
C#can not use excel's vba and owc spreedsheet can not excute vba code.
I should use c# to solve this problem.
for example:
axSpreadsheet1.sheets.get_Names().ToString();
but "sheets" does not have the get_Names() method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top