Naming Excel Ranges with VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ruger7mm
    New Member
    • Sep 2007
    • 1

    Naming Excel Ranges with VBA

    Hi all,
    I have 3 columns in a spreadsheet that I am provided that contains 3 columns (Name1 in Column A, Name2 in Column B, and ID in Column C) and would like to use the value in Column C to name a range that consists of Column A and B. I would like to do this for each row and have tried to record a Macro but to no avail. Here is the code that I have (that gives me a Run-Time error '438')


    Sub SetUpRanges()

    For NumRows = 1 To 5
    Worksheets("She et1").Range ("(Cells(NumRow s + 1, 3))")
    ActiveWorkbook. Names.Add Name:="(Cells(N umRows + 1, 3))", _
    RefersTo:="=She et1!((Cells(Num Rows + 1, 1)):(Cells(NumR ows + 1,2)))"

    Next NumRows

    End Sub


    Can anybody help?
    Bob

    P.S. I'm using Excel 2003
    Last edited by ruger7mm; Sep 18 '07, 06:29 PM. Reason: Left out Excel version
Working...