473,378 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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("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?
Bob

P.S. I'm using Excel 2003
Sep 18 '07 #1
0 882

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

Similar topics

0
by: Steve T | last post by:
I have a script which creates an excel workbook, dumps a load of data into it and calls the following code. The ranges are created from a query and relate to the data that has just been added to...
1
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed...
2
by: Jerry | last post by:
I am rewriting my vba routines to C# to increase speed. I have been unable to find any help on how to pass ranges to C#. Excel function that was called in VBA...
7
by: Alan Roberts | last post by:
Can someone please explain the following for me... I am trying to link to a .NET DLL from Excel. Excel needs to pass a reference to itself to the DLL and then the DLL needs to perform some work...
6
by: Elena | last post by:
I'm trying to export data to an Excel worksheet. I can export the data in the cell values perfectly. I need the code to change a header and footer for the worksheet, not for the columns. Is...
5
by: Elena | last post by:
I need the VB.NET code to change the header/footer of an Excel spread sheet, ASAP. I am doing it through a VB application. I can change the ranges/cell values using code, but I do not know how to...
6
by: Gunawan | last post by:
Dear All, I have create an excel (COM Object) using this code Excel.Application xls = new Excel.Application(); but I can not remove it from memory although I have using close and quit ...
3
by: D.Stone | last post by:
I'm trying to import an Excel spreadsheet into an existing Access table using Office 2003. Ultimately, the plan is to do it programmatically using TransferSpreadsheet, but to check that the file...
4
by: laurasesma18 | last post by:
I've got a convertion tool with Access 2003. It imports an excel sheet into the data base and with the records in it creats different outputfiles. Its programmed with VBA. Now what I need is, in...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.