Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Auto size named range by .Net or VBA

Thanks, Jialiang. That helps a lot with my assessment for the customer.

Dale


"Jialiang Ge [MSFT]" wrote:

Hello Dale,

From your post, my understanding on this issue is: you want to know how to
dynamically resize the Named Range when new rows are appended to it and how
to adjust the named range below the table. If I'm off base, please feel
free to let me know.

For the first question, Named range will be adjusted automatically if the
Insert (row) method is called on cells within it. Suppose we get the Range
object of the last row and call its 'Insert' method, we may find that the
new row is automatically added into the named range:
Excel.Range lastRow = (Excel.Range)name.RefersToRange.Rows[rows.Count,
missing];
lastRow.Insert(Excel.XlDirection.xlDown, true);
But unfortunately, Excel does not support inserting a row below the caller
(such as the 'lastRow' in the above code). The new blank row appears before
the 'lastRow'. A possible workaround is to temporarily make the original
named range include an extra row beneath the last data row, then call
Insert on this extra row. When the datasets are imported, we remove the row
from the named range.

As FSt1 suggested, another method is to adjust the named range every time
when a new row or cell is added by calling NamedRange.RefersToR1C1 = <new
range.

For the second question, the named ranges below the table will be shifted
automatically by Excel when new rows are added to the table.

Please let me know if you have any other concerns, or need anything else.

Sincerely,
Jialiang Ge , remove 'online.')
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


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
auto insert worksheet name in dynamic named range maijiuli Excel Programming 3 August 15th 07 12:22 AM
Auto-detect range size shelfish Excel Programming 4 May 19th 06 10:21 PM
increasing the size of a named range and saving it back to the spreadsheetI [email protected] Excel Programming 4 April 27th 06 11:59 PM
Cannot Expand Named Range - when size of the Range exceeds Snig Excel Discussion (Misc queries) 1 July 7th 05 01:46 PM
determine range size after auto filter? Jeff Excel Programming 3 December 30th 04 10:34 PM


All times are GMT +1. The time now is 02:26 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"