Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
excel sheet bootom half sheet goes behind top part of sheet | Excel Worksheet Functions | |||
Duplicate sheet, autonumber sheet, record data on another sheet | Excel Worksheet Functions | |||
How do I select price from sheet.b where sheet.a part no = sheet.b | Excel Worksheet Functions | |||
relative sheet references ala sheet(-1)!B11 so I can copy a sheet. | Excel Discussion (Misc queries) | |||
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 | Excel Programming |