Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error: Cannot expand named range

Hi,

I am trying to insert some records into an excel sheet thru Named range.

I could have used the Sheet name but the field names actually start after
skipping first 10 rows (reserved for a header) so the ADO driver does not
recognize the table if I dont use a named range. Here are the details:

Name of range: Rang1
Range Formula: =Product_Pricing!$C$10 : $E$10
The 10th row contains the field names. Right now, it only has 3 fields.

When I insert a record using an SQL Insert, it inserts the records fine but
when I try to insert another record, it gives me this error: "Cannot exapand
named range".

I know why it gives the error, but I want to know if there is way to expand
the range as the records are added.

I could accomplish this using an unnamed range and keeping a track of the
current range using a counter in my code, and increment it everytime a record
is added but this approach is not flexible. I have to insert a value for all
the columns in that range, and I cannot use an SQL query like this where I
can specify the field names:

INSERT INTO [Product_Pricing$C" + i + ":E" + i + "](PARTNUMBER, DESCRIP,
QTY) VALUES ('Part1', 'Description','1')";

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Error: Cannot expand named range

Why not use an OFFSET function to get your range

Assumptions:

THe only data in row 10 is is field names
THere is nothing in cells B10 or A10. If there is, a change will need to be
made

=OFFSET(Sheet1!$C$10,0,0,COUNTA($10:$10),1)

You may need to subtract something from COUNTA if there is something in A10
or B10.

HTH,
Barb Reinhardt


"bullpit" wrote:

Hi,

I am trying to insert some records into an excel sheet thru Named range.

I could have used the Sheet name but the field names actually start after
skipping first 10 rows (reserved for a header) so the ADO driver does not
recognize the table if I dont use a named range. Here are the details:

Name of range: Rang1
Range Formula: =Product_Pricing!$C$10 : $E$10
The 10th row contains the field names. Right now, it only has 3 fields.

When I insert a record using an SQL Insert, it inserts the records fine but
when I try to insert another record, it gives me this error: "Cannot exapand
named range".

I know why it gives the error, but I want to know if there is way to expand
the range as the records are added.

I could accomplish this using an unnamed range and keeping a track of the
current range using a counter in my code, and increment it everytime a record
is added but this approach is not flexible. I have to insert a value for all
the columns in that range, and I cannot use an SQL query like this where I
can specify the field names:

INSERT INTO [Product_Pricing$C" + i + ":E" + i + "](PARTNUMBER, DESCRIP,
QTY) VALUES ('Part1', 'Description','1')";

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Expand a Named Range in 2007 Nanette New Users to Excel 2 April 26th 07 10:08 PM
"Cannot expand named range" JH Excel Programming 3 February 7th 07 06:22 PM
Cannot Expand Named Range - when size of the Range exceeds Snig Excel Discussion (Misc queries) 1 July 7th 05 01:46 PM
Excel Driver Error: Cannot expand named range Helene Pinol Excel Programming 0 April 2nd 04 11:32 AM
Excel Driver Error: Cannot Expand Named Range Helene Pinol Excel Programming 0 April 1st 04 05:39 PM


All times are GMT +1. The time now is 09:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"