SheetName (Application.Caller.Parent.Name) Forces Excel to Save File

  • Thread starter Thread starter Mike McCollister
  • Start date Start date
M

Mike McCollister

I have a VBA function in Excel that I have been using for years that will
display the sheet name in a cell. The VBA function is as follows:

Function SheetName() As String
Application.Volatile
SheetName = Application.Caller.Parent.Name
End Function

This works great. However, I have found that if I am using this function if
I open a worksheet and not change anything Excel will prompt me if I want to
save the worksheet if I have not made any changes. Why is this happening and
is there a way to prevent this from happening?

Thanks,

Mike
 
The problem may be Application.Volitile

If the function re-calculates, Excel may suspect that the worksheet has
changed.
 
You could just use a worksheet function

=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,99)

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)
 
It will always recalculate upon opening, so it is definitely the
Application.Volatile.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)
 
Won't this suffer the same volatility problem?

Bob said:
You could just use a worksheet function

=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,99)

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

Mike McCollister said:
I have a VBA function in Excel that I have been using for years that will
display the sheet name in a cell. The VBA function is as follows:

Function SheetName() As String
Application.Volatile
SheetName = Application.Caller.Parent.Name
End Function

This works great. However, I have found that if I am using this function if
I open a worksheet and not change anything Excel will prompt me if I want to
save the worksheet if I have not made any changes. Why is this happening and
is there a way to prevent this from happening?

Thanks,

Mike
 
Dang. If I remove that applicaiton.volatile it is not updating. I guess that
I will stay with the function.

Mike
 
I'll consider that. It is just not as friendly as the SheetName function
that I have written up.

Mike

Bob Phillips said:
You could just use a worksheet function

=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,99)

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

Mike McCollister said:
I have a VBA function in Excel that I have been using for years that will
display the sheet name in a cell. The VBA function is as follows:

Function SheetName() As String
Application.Volatile
SheetName = Application.Caller.Parent.Name
End Function

This works great. However, I have found that if I am using this function if
I open a worksheet and not change anything Excel will prompt me if I want to
save the worksheet if I have not made any changes. Why is this happening and
is there a way to prevent this from happening?

Thanks,

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top