Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to get the available sheet name

Hi,
I need to add a new sheet thru macros which i have done. But now
need to know the sheets name that alreday been existing.
I got the sheets.count. But i am not getting the name of the sheet.

How to know this.
Can any one help me to reach this

Thanks
Venkatesh

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to get the available sheet name

Venkatesh,

You have two choices AFAICS, that is loope through all sheets and put the
name into an array, and check your proposed name against that, or try and
create it, and if it exists, try with a new name.

Here is some code to test if it exists

Function SheetExists(Filename As String)
Dim oSh As Worksheet
On Error Resume Next
Set oSh = ActiveWorkbook.Worksheets(Filename)
On Error GoTo 0
SheetExists = Not oSh Is Nothing
End Function


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"kvenku " wrote in message
...
Hi,
I need to add a new sheet thru macros which i have done. But now i
need to know the sheets name that alreday been existing.
I got the sheets.count. But i am not getting the name of the sheet.

How to know this.
Can any one help me to reach this

Thanks
Venkatesh.


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to get the available sheet name

I need to know the list of sheet name which are available..example
Sheet1,Sheet2,Sheet3...like that

How to add a new sheet with a name given my me thru text box in the
VBA.

It would be very helpful if you do this for me

Thanks
venkatesh.


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to get the available sheet name

The available sheet names is infinite, because they can be whatever you
want.

If yoiu names are all Sheet1,2, 3, 4 format, try this

iNext = Activeworkbook.Worksheets.Count + 1
Do Until Not SheetExists("Sheet" & iNext)
iNext = iNext + 1
Loop
Woeksheets.Add.Name = "Sheet" & iNext



Function SheetExists(Filename As String)
Dim oSh As Worksheet
On Error Resume Next
Set oSh = ActiveWorkbook.Worksheets(Filename)
On Error GoTo 0
SheetExists = Not oSh Is Nothing
End Function


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"kvenku " wrote in message
...
I need to know the list of sheet name which are available..example
Sheet1,Sheet2,Sheet3...like that

How to add a new sheet with a name given my me thru text box in the
VBA.

It would be very helpful if you do this for me

Thanks
venkatesh.


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to get the available sheet name

My Sheet may contain any name is sheet not sheet1.2.3...

In my case i need to populate the available sheet names into th
listbox. Is there any way to find that .

Please reply me faster

Thanks

Venkatesh

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default How to get the available sheet name

If I understand what you are saying, here's an example:

Sub PopulateListBox()
Dim ws As Worksheet
For Each ws In Worksheets
ListBox1.AddItem ws.Name
Next
End Sub

--

Vasant


"kvenku " wrote in message
...
My Sheet may contain any name is sheet not sheet1.2.3...

In my case i need to populate the available sheet names into the
listbox. Is there any way to find that .

Please reply me faster

Thanks

Venkatesh.


---
Message posted from http://www.ExcelForum.com/



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to get the available sheet name

Then you will have to the other way around.

Get the value from the text box, test if the sheet already exists, if not
create it, if so, error and tell the user.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"kvenku " wrote in message
...
My Sheet may contain any name is sheet not sheet1.2.3...

In my case i need to populate the available sheet names into the
listbox. Is there any way to find that .

Please reply me faster

Thanks

Venkatesh.


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel sheet bootom half sheet goes behind top part of sheet rob Excel Worksheet Functions 2 January 17th 09 01:28 AM
Duplicate sheet, autonumber sheet, record data on another sheet des-sa[_2_] Excel Worksheet Functions 0 May 8th 08 06:56 PM
How do I select price from sheet.b where sheet.a part no = sheet.b Sonny Excel Worksheet Functions 4 April 4th 06 05:08 PM
relative sheet references ala sheet(-1)!B11 so I can copy a sheet. RonMc5 Excel Discussion (Misc queries) 9 February 3rd 05 12:51 AM
Inserting a row in sheet A should Insert a row in sheet B, removing a row in Sheet A should remove the corresponding row in sheet B Hannes Heckner Excel Programming 1 March 5th 04 09:10 AM


All times are GMT +1. The time now is 02:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"