By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,600 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,600 IT Pros & Developers. It's quick & easy.

Naming Excel Ranges with VBA

P: 1
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("Sheet1").Range ("(Cells(NumRows + 1, 3))")
ActiveWorkbook.Names.Add Name:="(Cells(NumRows + 1, 3))", _
RefersTo:="=Sheet1!((Cells(NumRows + 1, 1)):(Cells(NumRows + 1,2)))"

Next NumRows

End Sub

Can anybody help?

P.S. I'm using Excel 2003
Sep 18 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.