Consulting

Results 1 to 3 of 3

Thread: Solved: Name Ranges

  1. #1

    Solved: Name Ranges

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Fantastic - thank you for the extremely quick response

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •