ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with Named Cells (https://www.excelbanter.com/excel-programming/332180-problem-named-cells.html)

Mats Samson

Problem with Named Cells
 
Hello,
I've a problem that I cannot change/move a named cell to another location.
To copy information to a specific cell in the worksheet I named it (LastCell).
When I've copied the information, I want to name the next cell below to the
same name but it does not work. Here is how it looks:
Sub DocFinalize()
CurrDoc = Worksheets("Docs").Range("DocType")
Worksheets("Docs").Range("DocLine").Copy
With Worksheets("Docs").Range("LastCell")
.Select
.PasteSpecial (xlValues) ' (It copies several cell values from the
ranged row"DocLine")
.PasteSpecial (xlFormats)
End With
Application.CutCopyMode = False
Worksheets("Docs").Range("LastCell").Select
ActiveCell.Offset(1, 0).Names Add = "LastCell"
I can navigate properly to the new cell but it doesn't matter how I do it,
I can never name the cell to LastCell like I do when selecting
Insert/Name/Define/....
Strangely, I can name the cell with the Value in the previous cell but never
the Name
Looking forward to your (simple) solutions!?!?
Best regards
Mats


Bob Umlas, Excel MVP

Problem with Named Cells
 
ActiveCell.Offset(1, 0).Names Add = "LastCell"
this is an invalid statement. Ranges don't have a Names property. Workbooks
do.
Try Activecell.Offset(1,0).Name = "LastCell"


"Mats Samson" wrote:

Hello,
I've a problem that I cannot change/move a named cell to another location.
To copy information to a specific cell in the worksheet I named it (LastCell).
When I've copied the information, I want to name the next cell below to the
same name but it does not work. Here is how it looks:
Sub DocFinalize()
CurrDoc = Worksheets("Docs").Range("DocType")
Worksheets("Docs").Range("DocLine").Copy
With Worksheets("Docs").Range("LastCell")
.Select
.PasteSpecial (xlValues) ' (It copies several cell values from the
ranged row"DocLine")
.PasteSpecial (xlFormats)
End With
Application.CutCopyMode = False
Worksheets("Docs").Range("LastCell").Select
ActiveCell.Offset(1, 0).Names Add = "LastCell"
I can navigate properly to the new cell but it doesn't matter how I do it,
I can never name the cell to LastCell like I do when selecting
Insert/Name/Define/....
Strangely, I can name the cell with the Value in the previous cell but never
the Name
Looking forward to your (simple) solutions!?!?
Best regards
Mats


Mats Samson

Problem with Named Cells
 
Thank you Bob, it helped, and it was simple too.
Best regards
Mats

"Bob Umlas, Excel MVP" wrote:

ActiveCell.Offset(1, 0).Names Add = "LastCell"
this is an invalid statement. Ranges don't have a Names property. Workbooks
do.
Try Activecell.Offset(1,0).Name = "LastCell"


"Mats Samson" wrote:

Hello,
I've a problem that I cannot change/move a named cell to another location.
To copy information to a specific cell in the worksheet I named it (LastCell).
When I've copied the information, I want to name the next cell below to the
same name but it does not work. Here is how it looks:
Sub DocFinalize()
CurrDoc = Worksheets("Docs").Range("DocType")
Worksheets("Docs").Range("DocLine").Copy
With Worksheets("Docs").Range("LastCell")
.Select
.PasteSpecial (xlValues) ' (It copies several cell values from the
ranged row"DocLine")
.PasteSpecial (xlFormats)
End With
Application.CutCopyMode = False
Worksheets("Docs").Range("LastCell").Select
ActiveCell.Offset(1, 0).Names Add = "LastCell"
I can navigate properly to the new cell but it doesn't matter how I do it,
I can never name the cell to LastCell like I do when selecting
Insert/Name/Define/....
Strangely, I can name the cell with the Value in the previous cell but never
the Name
Looking forward to your (simple) solutions!?!?
Best regards
Mats



All times are GMT +1. The time now is 08:09 PM.

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