C
Clayman
It's two - two - two questions in one!
I am writing a formula to extract the sheet name from a cell reference.
Here's my code:
Function sheetname(sell As String) As String
exclpoint = InStr(sell, "!")
sheetname = Left$(sell, exclpoint - 1)
End Function
I've tested this code in the following sub and it worked:
Private Sub cheetname()
sell = "Sheet1!A1"
exclamationpoint = InStr(sell, "!")
thename = Left$(sell, exclamationpoint - 1)
okeedokee = MsgBox(thename, vbOKOnly)
End Sub
But the function gives me a #NAME? error. So, my thinking is that I need to
define this as a range instead of a string. But how do I convert the range
type to a string?
Or, is the #NAME? error 'cuz I'm not calling the formula correctly?
=sheetname(Sheet1!A1)
I am writing a formula to extract the sheet name from a cell reference.
Here's my code:
Function sheetname(sell As String) As String
exclpoint = InStr(sell, "!")
sheetname = Left$(sell, exclpoint - 1)
End Function
I've tested this code in the following sub and it worked:
Private Sub cheetname()
sell = "Sheet1!A1"
exclamationpoint = InStr(sell, "!")
thename = Left$(sell, exclamationpoint - 1)
okeedokee = MsgBox(thename, vbOKOnly)
End Sub
But the function gives me a #NAME? error. So, my thinking is that I need to
define this as a range instead of a string. But how do I convert the range
type to a string?
Or, is the #NAME? error 'cuz I'm not calling the formula correctly?
=sheetname(Sheet1!A1)