ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   checking if a range has a name. (https://www.excelbanter.com/excel-programming/316237-checking-if-range-has-name.html)

Peter[_21_]

checking if a range has a name.
 
Hello everyone,

Let's say I have given the name "automobile" to cell B7.
If that cell is selected at a certain moment, is is possible to retrieve the
name "automobile" that has been given to it?

I'd like to do something along the lines of (free styling) :
if the name of the active cell =
"automobile" then .... etc. etc.

Does anyone have code for this kind of thing?

Thanks,
Peter



Dave Peterson[_5_]

checking if a range has a name.
 
Maybe:

Option Explicit
Sub testme()

Dim myName As String
myName = ""
On Error Resume Next
myName = ActiveCell.Name.Name
On Error GoTo 0

If myName = "" Then
MsgBox "no name"
Else
MsgBox "It's: " & myName
End If
End Sub



Peter wrote:

Hello everyone,

Let's say I have given the name "automobile" to cell B7.
If that cell is selected at a certain moment, is is possible to retrieve the
name "automobile" that has been given to it?

I'd like to do something along the lines of (free styling) :
if the name of the active cell =
"automobile" then .... etc. etc.

Does anyone have code for this kind of thing?

Thanks,
Peter


--

Dave Peterson


All times are GMT +1. The time now is 04:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com