PDA

View Full Version : Solved: Name Ranges



kellyhell
03-25-2010, 07:52 AM
I have a list of names in a column and I want to name a range of cells based on the contents of the cells in that column.

For example

Cell M2 contains the name John Smith - cell M3 another name etc etc.

The range A2:M2 is to be named based on the contents of cell M2 (John Smith).

I know I can do this manually by using Insert>Name>Define but this will take a long time!!!.

Is there any VBA to automate this process? I have Googled this and cannot find exactly what I need.

TIA:think:

Bob Phillips
03-25-2010, 07:57 AM
With Activesheet

LastRow = .Cells(.Rows.Count, "M").End(xlUp).Row
For i = 2 To LastRow

.Cells(i, "A").Resize(1, 13).Name = Replace(.Cells(i, "M").Value2, " ", "_")
Next i
End With

kellyhell
03-25-2010, 08:03 AM
Fantastic - thank you for the extremely quick response:p