ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get a cell's name in VBA (https://www.excelbanter.com/excel-programming/292449-get-cells-name-vba.html)

Pallavi Singh

Get a cell's name in VBA
 
Hello,
Could anyone point out how to get a cell's name in the VBA code.
I am trying to retrieve a cell's name - for example suppose target is
the range object pointing to a single cell.
Following lines get the cell address instead of cell name.
target.Name or target.Cells(1, 1).Name
How do I get the cell's name instead of address?
Thanks in advance




Leo Heuser[_2_]

Get a cell's name in VBA
 
Pallavi

You have to use the name property twice:

Target.Name.Name

--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"Pallavi Singh" skrev i en meddelelse
...
Hello,
Could anyone point out how to get a cell's name in the VBA code.
I am trying to retrieve a cell's name - for example suppose target is
the range object pointing to a single cell.
Following lines get the cell address instead of cell name.
target.Name or target.Cells(1, 1).Name
How do I get the cell's name instead of address?
Thanks in advance






Pallavi Singh

Get a cell's name in VBA
 

Leo,
Thanx for your quick response.
The problem is that 'Name' is being exposed as a property. Hence
when I do a 'targetRange.Name.Name' I get a runtime error 'Object
doesn't support this property or method', error 438. Do I need to set
some sort of property to True to make this work?
Thanx


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Leo Heuser[_2_]

Get a cell's name in VBA
 
You're welcome, Pallavi.

Please post the full code + which
version of Excel you are using to the group.

I have to leave at 9.00, so if your
posting is later than that, I won't be
able to answer until this afternoon.
(right now it's 7.30 in the morning in Denmark)

--
Best Regards
Leo Heuser

Followup to newsgroup only please.


"Pallavi Singh" skrev i en meddelelse
...

Leo,
Thanx for your quick response.
The problem is that 'Name' is being exposed as a property. Hence
when I do a 'targetRange.Name.Name' I get a runtime error 'Object
doesn't support this property or method', error 438. Do I need to set
some sort of property to True to make this work?
Thanx


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Pallavi Singh

Get a cell's name in VBA
 
Hi Leo,

Actually using targetRange.Name.Name did solve the problem.
I don't know why it din't work 1st time. But its working right now.
Thanks for your help :)



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Leo Heuser[_2_]

Get a cell's name in VBA
 
Glad it worked for you, Pallavi :-)
Thanks for the feedback.

--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"Pallavi Singh" skrev i en meddelelse
...
Hi Leo,

Actually using targetRange.Name.Name did solve the problem.
I don't know why it din't work 1st time. But its working right now.
Thanks for your help :)





All times are GMT +1. The time now is 03:39 PM.

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