ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range Naming using cell data (https://www.excelbanter.com/excel-programming/299677-range-naming-using-cell-data.html)

Ronny Hamida[_2_]

Range Naming using cell data
 
And one final question!

I'm not sure if I have to initialize any variables in my
macro for this one. I'd like to define a cell name using
the first four characters from another cell.

Here's what I had tried, but obviously I'd get an invalid
name:

ActiveWorkbook.Names.Add Name:=Left(Cells
(row_index, "D").Value, 4), RefersToR1C1:=Cells(row_index
+ 1, "C")

Here's a sample cut of the data:

Column C Column D
1 xxxx99999
1 xxxx99999
TOTAL: 2 (blank)

I want to define the cell with TOTAL as "xxxx"

Thank you all again for the assistance!
Ronny


Tom Ogilvy

Range Naming using cell data
 

Cells(row_index + 1, "C").Name = Left(Cells(row_index, "D").Value)

--
Regards,
Tom Ogilvy


"Ronny Hamida" wrote in message
...
And one final question!

I'm not sure if I have to initialize any variables in my
macro for this one. I'd like to define a cell name using
the first four characters from another cell.

Here's what I had tried, but obviously I'd get an invalid
name:

ActiveWorkbook.Names.Add Name:=Left(Cells
(row_index, "D").Value, 4), RefersToR1C1:=Cells(row_index
+ 1, "C")

Here's a sample cut of the data:

Column C Column D
1 xxxx99999
1 xxxx99999
TOTAL: 2 (blank)

I want to define the cell with TOTAL as "xxxx"

Thank you all again for the assistance!
Ronny




Bob Phillips[_6_]

Range Naming using cell data
 
Not sure if you have a problem, but it is easier to use

ActiveWorkbook.Activesheet.Cells(row_index + 1, "C").Name=Left(Cells
(row_index, "D").Value, 4)


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Ronny Hamida" wrote in message
...
And one final question!

I'm not sure if I have to initialize any variables in my
macro for this one. I'd like to define a cell name using
the first four characters from another cell.

Here's what I had tried, but obviously I'd get an invalid
name:

ActiveWorkbook.Names.Add Name:=Left(Cells
(row_index, "D").Value, 4), RefersToR1C1:=Cells(row_index
+ 1, "C")

Here's a sample cut of the data:

Column C Column D
1 xxxx99999
1 xxxx99999
TOTAL: 2 (blank)

I want to define the cell with TOTAL as "xxxx"

Thank you all again for the assistance!
Ronny




Ronny[_2_]

Range Naming using cell data
 
Thank you both! Works perfectly!

Cheers,
Ronny


All times are GMT +1. The time now is 12:32 PM.

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