Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Sheets names

Hi Guys,

I need a VBA to sort all the sheet's names in a column,
Can this list be updated automatically In case I delete any sheets?

Can anyone please direct me to create such VBA?

Thanks in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Sheets names

HI

Sub listSheets()
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

Regards
Peter

"2007-User" wrote:

Hi Guys,

I need a VBA to sort all the sheet's names in a column,
Can this list be updated automatically In case I delete any sheets?

Can anyone please direct me to create such VBA?

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Sheets names

Thank you so much Peter

How can I make it auto_refreshable in case I add/removed or renamed any
sheets?

Thanks again.


"PeterAtherton" wrote in message
...
HI

Sub listSheets()
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

Regards
Peter

"2007-User" wrote:

Hi Guys,

I need a VBA to sort all the sheet's names in a column,
Can this list be updated automatically In case I delete any sheets?

Can anyone please direct me to create such VBA?

Thanks in advance.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Sheets names

Hi
Right-click on the Excel icon at the left of the file toolbar and choose
View Code. This opens the Workbook code sheet. Copy the revised formula into
the code.

Private Sub workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As Boolean)
'sheets("Menu").select
'cells(4,2).select
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

Beware the code write the sheets every time you save the workbook. in this
case I think you should insert lines to place the list on a particular sheet
and lines.

I've added a couple of lines to the code to give you the idea; just remove
the rems (apostrophes) if they are suitable

Regards
Peter
"2007-User" wrote:

Thank you so much Peter

How can I make it auto_refreshable in case I add/removed or renamed any
sheets?

Thanks again.


"PeterAtherton" wrote in message
...
HI

Sub listSheets()
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

Regards
Peter

"2007-User" wrote:

Hi Guys,

I need a VBA to sort all the sheet's names in a column,
Can this list be updated automatically In case I delete any sheets?

Can anyone please direct me to create such VBA?

Thanks in advance.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Sheets names

I have not woken up yet. You might delete sheets so you will need to clear
the original list. The rest is OK - it still goes in the workbook module.

Private Sub workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As Boolean)
Sheets("Menu").Select
Range("B2").Select
' you might delete sheets so the updated
' list will be smaller
Range("B2").CurrentRegion.ClearContents
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

regards


"PeterAtherton" wrote:

Hi
Right-click on the Excel icon at the left of the file toolbar and choose
View Code. This opens the Workbook code sheet. Copy the revised formula into
the code.

Private Sub workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As Boolean)
'sheets("Menu").select
'cells(4,2).select
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

Beware the code write the sheets every time you save the workbook. in this
case I think you should insert lines to place the list on a particular sheet
and lines.

I've added a couple of lines to the code to give you the idea; just remove
the rems (apostrophes) if they are suitable

Regards
Peter
"2007-User" wrote:

Thank you so much Peter

How can I make it auto_refreshable in case I add/removed or renamed any
sheets?

Thanks again.


"PeterAtherton" wrote in message
...
HI

Sub listSheets()
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

Regards
Peter

"2007-User" wrote:

Hi Guys,

I need a VBA to sort all the sheet's names in a column,
Can this list be updated automatically In case I delete any sheets?

Can anyone please direct me to create such VBA?

Thanks in advance.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Sheets names

Thanks so much Peter you help me a lot.

"PeterAtherton" wrote in message
...
I have not woken up yet. You might delete sheets so you will need to clear
the original list. The rest is OK - it still goes in the workbook module.

Private Sub workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As
Boolean)
Sheets("Menu").Select
Range("B2").Select
' you might delete sheets so the updated
' list will be smaller
Range("B2").CurrentRegion.ClearContents
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

regards


"PeterAtherton" wrote:

Hi
Right-click on the Excel icon at the left of the file toolbar and choose
View Code. This opens the Workbook code sheet. Copy the revised formula
into
the code.

Private Sub workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As
Boolean)
'sheets("Menu").select
'cells(4,2).select
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

Beware the code write the sheets every time you save the workbook. in
this
case I think you should insert lines to place the list on a particular
sheet
and lines.

I've added a couple of lines to the code to give you the idea; just
remove
the rems (apostrophes) if they are suitable

Regards
Peter
"2007-User" wrote:

Thank you so much Peter

How can I make it auto_refreshable in case I add/removed or renamed any
sheets?

Thanks again.


"PeterAtherton" wrote in
message
...
HI

Sub listSheets()
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

Regards
Peter

"2007-User" wrote:

Hi Guys,

I need a VBA to sort all the sheet's names in a column,
Can this list be updated automatically In case I delete any sheets?

Can anyone please direct me to create such VBA?

Thanks in advance.








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Sheets names

Peter,

1- Can I call this list_refresher when I am switching between the sheets?
2- I have a little problem, when I am in other sheets, when I push the save
bottom the list create itself on that sheet also, is there anyway to lead
the program to run itself just on that specific sheet?

Thanks again.



"PeterAtherton" wrote in message
...
I have not woken up yet. You might delete sheets so you will need to clear
the original list. The rest is OK - it still goes in the workbook module.

Private Sub workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As
Boolean)
Sheets("Menu").Select
Range("B2").Select
' you might delete sheets so the updated
' list will be smaller
Range("B2").CurrentRegion.ClearContents
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

regards


"PeterAtherton" wrote:

Hi
Right-click on the Excel icon at the left of the file toolbar and choose
View Code. This opens the Workbook code sheet. Copy the revised formula
into
the code.

Private Sub workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As
Boolean)
'sheets("Menu").select
'cells(4,2).select
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

Beware the code write the sheets every time you save the workbook. in
this
case I think you should insert lines to place the list on a particular
sheet
and lines.

I've added a couple of lines to the code to give you the idea; just
remove
the rems (apostrophes) if they are suitable

Regards
Peter
"2007-User" wrote:

Thank you so much Peter

How can I make it auto_refreshable in case I add/removed or renamed any
sheets?

Thanks again.


"PeterAtherton" wrote in
message
...
HI

Sub listSheets()
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

Regards
Peter

"2007-User" wrote:

Hi Guys,

I need a VBA to sort all the sheet's names in a column,
Can this list be updated automatically In case I delete any sheets?

Can anyone please direct me to create such VBA?

Thanks in advance.








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Sheets names

I found a solution to solve my 2nd problem which is using activesheet code,
please see below:

If ActiveSheet.Name = "COVER SHEET" Then
listSheets 'call listsheets module


"2007-User" wrote in message
...
Peter,

1- Can I call this list_refresher when I am switching between the sheets?
2- I have a little problem, when I am in other sheets, when I push the
save bottom the list create itself on that sheet also, is there anyway to
lead the program to run itself just on that specific sheet?

Thanks again.



"PeterAtherton" wrote in message
...
I have not woken up yet. You might delete sheets so you will need to clear
the original list. The rest is OK - it still goes in the workbook module.

Private Sub workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As
Boolean)
Sheets("Menu").Select
Range("B2").Select
' you might delete sheets so the updated
' list will be smaller
Range("B2").CurrentRegion.ClearContents
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

regards


"PeterAtherton" wrote:

Hi
Right-click on the Excel icon at the left of the file toolbar and choose
View Code. This opens the Workbook code sheet. Copy the revised formula
into
the code.

Private Sub workbook_BeforeSave(ByVal SaveAsUi As Boolean, Cancel As
Boolean)
'sheets("Menu").select
'cells(4,2).select
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

Beware the code write the sheets every time you save the workbook. in
this
case I think you should insert lines to place the list on a particular
sheet
and lines.

I've added a couple of lines to the code to give you the idea; just
remove
the rems (apostrophes) if they are suitable

Regards
Peter
"2007-User" wrote:

Thank you so much Peter

How can I make it auto_refreshable in case I add/removed or renamed
any
sheets?

Thanks again.


"PeterAtherton" wrote in
message
...
HI

Sub listSheets()
s = Sheets.Count
r = ActiveCell.Row: c = ActiveCell.Column
For i = 1 To s
Cells(r, c) = Sheets(i).Name
Cells(r, c + 1) = Sheets(i).Index
r = r + 1
Next
End Sub

Regards
Peter

"2007-User" wrote:

Hi Guys,

I need a VBA to sort all the sheet's names in a column,
Can this list be updated automatically In case I delete any sheets?

Can anyone please direct me to create such VBA?

Thanks in advance.










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
Sheets Names in Formulas Ellen G Excel Discussion (Misc queries) 3 March 7th 08 11:51 PM
Sheets names Petros[_2_] Excel Discussion (Misc queries) 5 March 4th 08 06:03 PM
Cell Names in Two Sheets NHMM Excel Discussion (Misc queries) 5 May 25th 07 11:06 PM
cells and sheets, names PH NEWS Excel Worksheet Functions 3 February 20th 06 03:35 PM
how do i get the names of the sheets Reny J Joseph Thuthikattu Excel Worksheet Functions 1 December 11th 04 09:37 AM


All times are GMT +1. The time now is 03:17 AM.

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

About Us

"It's about Microsoft Excel"