Range Naming using cell data

R

Ronny Hamida

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
 
B

Bob Phillips

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top