We help IT Professionals succeed at work.

Excel sheet names

246 Views
Last Modified: 2013-12-17
Hi Guys
I am planning to do a report and i need a list of all sheetnames in one colums,is there a function that i can use to get sheet names
F(1) = Sheet#1's name
F(2) =Sheet#2's name
and so on
Comment
Watch Question

Rory ArchibaldGrand Poobah
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011

Commented:
Hi,
Do you mean as a formula in a cell?

Author

Commented:
yes
CERTIFIED EXPERT
Top Expert 2010
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2010

Commented:
titorober23,

Note also that that is a VBA, and not a C#, function...

Regards,

Patrick
CERTIFIED EXPERT
Top Expert 2010

Commented:
Typo...

Function SheetName(SheetIndex As Long)
 
    Application.Volatile
    SheetName = ThisWorkbook.Sheets(SheetIndex).Name
 
End Function
CERTIFIED EXPERT
Top Expert 2010

Commented:
Hm, it appears that it is automatically updating on a sheet rename--must be because the renaming itself
forces a recalc :)
Rory ArchibaldGrand Poobah
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Rory ArchibaldGrand Poobah
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2011

Commented:
Oops, should have refreshed!

Author

Commented:
it is giving me #NAME?
CERTIFIED EXPERT
Top Expert 2010

Commented:
titorober23,

Rory's use of the Caller method is a good one--my approach works breaks down if the UDF is used in an add-in
or personal macro workbook.  However, I think you need the Volatile bit to ensure updates when you change the
sheet names and/or order.  Combining the best bits of both...

Regards,

Patrick
Function SheetName(lngIndex As Long)
 
    With Application
        .Volatile
        SheetName = .Caller.Parent.Parent.Sheets(lngIndex).Name
    End With
 
End Function

Open in new window

CERTIFIED EXPERT
Top Expert 2010

Commented:
rorya said:
>>Oops, should have refreshed!

No worries, Rory--indeed, your post pointed to a better way of figuring out which Workbook to process :)
CERTIFIED EXPERT
Top Expert 2010
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.