ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Retrieving a Name of Cell (https://www.excelbanter.com/excel-programming/359925-retrieving-name-cell.html)

cheesey_toastie

Retrieving a Name of Cell
 
I wish to replace the cell references in a series of formulas with the
cells name.

For Each rngcell In rngRange
strFormula = rngcell.Formula
'and if the the formula begins with a '=' and DOES NOT contain a
'.'
If Left(strFormula, 1) = "=" And InStr(1, strFormula, ".") = 0
Then
'Then we need to iteratively replace each cell reference with a
name reference...

If InStr(strFormula, "+") = 0 Then ' then it is just in the
form '=A34'
Set rngcell2 =
shtCurrent.Range(Right(strFormula, Len(strFormula) - 1))
msgbox rngcell2.Name ' I would hope this returned the
cells name (e.g. TotalSales)

'here i will manipulate the string and replace the cell reference with
a named ref.
End if

Next

The problem is that the rngCell2.Name returns the cells other name
(e.g. SheetName!$A$34)

How do I get the given name?

Many thanks for any help
steve


cheesey_toastie

Retrieving a Name of Cell
 
Found it....

very very very simple!!!

rngCell2.Name.Name

Hope this helps someone else!

Steve



All times are GMT +1. The time now is 01:42 PM.

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