ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I get all worksheets' names of the spreadsheet? (https://www.excelbanter.com/excel-programming/382580-how-can-i-get-all-worksheets-names-spreadsheet.html)

marxi

How can I get all worksheets' names of the spreadsheet?
 
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!
--
marxi

RichardSchollar

How can I get all worksheets' names of the spreadsheet?
 
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


On 5 Feb, 07:45, marxi wrote:
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!
--
marxi




marxi

How can I get all worksheets' names of the spreadsheet?
 
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.

--
marxi


"RichardSchollar" wrote:

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


On 5 Feb, 07:45, marxi wrote:
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!
--
marxi





Dave Peterson

How can I get all worksheets' names of the spreadsheet?
 
In excel's vba:
Dim ws as worksheet


marxi wrote:

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.

--
marxi

"RichardSchollar" wrote:

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


On 5 Feb, 07:45, marxi wrote:
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!
--
marxi





--

Dave Peterson

marxi

How can I get all worksheets' names of the spreadsheet?
 
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.
--
marxi


"Dave Peterson" wrote:

In excel's vba:
Dim ws as worksheet


marxi wrote:

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.

--
marxi

"RichardSchollar" wrote:

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


On 5 Feb, 07:45, marxi wrote:
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!
--
marxi




--

Dave Peterson


Dave Peterson

How can I get all worksheets' names of the spreadsheet?
 
Maybe someone will jump in with the solution.

marxi wrote:

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.
--
marxi

"Dave Peterson" wrote:

In excel's vba:
Dim ws as worksheet


marxi wrote:

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.

--
marxi

"RichardSchollar" wrote:

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


On 5 Feb, 07:45, marxi wrote:
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!
--
marxi




--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 09:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com