Excel VBA - Code for getting the name of a cell?

AndresHernando
AndresHernando used Ask the Experts™
on
I'm trying to write code that will return the user names that have been given to cells.

What I tried below gives cell names like 'Sheet1'!$B$10
I actually need the name that has been given to that cell, which in this case happens to be "db1_Rd_PPRnum" (that is, the Name Manager name, not the cell reference)


Sub M_CellNames_Td_db1_CommonInfo()
    Dim rCell As Range
    Dim rRangeWithNamedCells As Range
   
    Set rRangeWithNamedCells = [Td_db1_CommonInfo]
   
    For Each rCell In rRangeWithNamedCells
        Cells([c_db1_CommonInfo_CellNames_Cell1].Row, rCell.Column).Value = rCell.Name
        Next rCell
End Sub
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
try

Cells([c_db1_CommonInfo_CellNames_Cell1].Row, rCell.Column).Value = rCell.Name.Name

(there is an additional Name at the end).

Ss

Author

Commented:
Shah254,
Nice!!!!  

Thanks, --Andres

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial