Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Programmatic row insertion error; KB211769 no help

Let me start by saying that I have read the Knowledge Base article #211769,
in addition to dozens of other posts regarding row insertion errors, but have
yet to find a solution that fixes this problem for me.

I am receiving the "To prevent possible loss of data, Microsoft Office Excel
cannot shift nonblank cells off the worksheet." error when I try to
programmatically insert a range via VBA macro:
Worksheet.Range("MyRange").Select
Worksheet.Rows.Insert (xlShiftDown)

Here are some additional details:
€¢ I am working with Windows XP Professional & Excel 2003 (11.8302.8221),
both w/SP3
€¢ I am able to manually perform the desired insert at design time, but
cannot do the same when I call the macro from a compiled DLL or the Visual
Studio 2005 IDE.
€¢ My worksheet contains no comments, objects, or merged cells.
o <F5 [Special...] 'Comments' produces a "no cells were found" message
o <F5 [Special...] 'Objects' produces a "no objects found" message
€¢ <ctrl<end places the cursor in the last cell used in my worksheet (K3)
o I have deleted all unused rows & columns in the worksheet & saved, to no
avail.
€¢ The named range I am selecting is a single row that spans the entire width
of my used area (A-K3).

My original worksheet was far more complex, but I have gone so far as to
start with a completely new worksheet and the 3 empty rows that I am trying
to populate programmatically, ensuring that there are no merged cells or
other objects n the document, yet I still receive the error.

Can anyone provide additional suggestions/assistance??

Thank you in advance for any help,
Aaron

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Programmatic row insertion error; KB211769 no help

Aaron,

The problem is with the ROWS.Insert - you cannot insert a ROW into the ROWS collection because there
is a set number of ROWS on a sheet. You can insert a row, however, just not within the ROWS
collection of the sheet. Go figure...

Try it this way:

Range("MyRange").Insert

or

Range("MyRange").EntireRow.Insert

And note that -

Worksheet

needs to be

ActiveSheet
or
Worksheets("Name of Sheet")

at least from within VBA - maybe not from within a DLL or COM, but I don't know those
restrictions....

HTH,
Bernie
MS Excel MVP


"Aaron Rolloff" wrote in message
...
Let me start by saying that I have read the Knowledge Base article #211769,
in addition to dozens of other posts regarding row insertion errors, but have
yet to find a solution that fixes this problem for me.

I am receiving the "To prevent possible loss of data, Microsoft Office Excel
cannot shift nonblank cells off the worksheet." error when I try to
programmatically insert a range via VBA macro:
Worksheet.Range("MyRange").Select
Worksheet.Rows.Insert (xlShiftDown)

Here are some additional details:
. I am working with Windows XP Professional & Excel 2003 (11.8302.8221),
both w/SP3
. I am able to manually perform the desired insert at design time, but
cannot do the same when I call the macro from a compiled DLL or the Visual
Studio 2005 IDE.
. My worksheet contains no comments, objects, or merged cells.
o <F5 [Special...] 'Comments' produces a "no cells were found" message
o <F5 [Special...] 'Objects' produces a "no objects found" message
. <ctrl<end places the cursor in the last cell used in my worksheet (K3)
o I have deleted all unused rows & columns in the worksheet & saved, to no
avail.
. The named range I am selecting is a single row that spans the entire width
of my used area (A-K3).

My original worksheet was far more complex, but I have gone so far as to
start with a completely new worksheet and the 3 empty rows that I am trying
to populate programmatically, ensuring that there are no merged cells or
other objects n the document, yet I still receive the error.

Can anyone provide additional suggestions/assistance??

Thank you in advance for any help,
Aaron



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Programmatic row insertion error; KB211769 no help

We have a winner! Your solution corrected the problem in both my simplified
worksheet, as well as my original, more complex template. In retrospect,
that method makes much more sense than what i was attempting to do
previously.

Thank you so much for your help!!!
Aaron


"Bernie Deitrick" wrote:

Aaron,

The problem is with the ROWS.Insert - you cannot insert a ROW into the ROWS collection because there
is a set number of ROWS on a sheet. You can insert a row, however, just not within the ROWS
collection of the sheet. Go figure...

Try it this way:

Range("MyRange").Insert

or

Range("MyRange").EntireRow.Insert

And note that -

Worksheet

needs to be

ActiveSheet
or
Worksheets("Name of Sheet")

at least from within VBA - maybe not from within a DLL or COM, but I don't know those
restrictions....

HTH,
Bernie
MS Excel MVP


"Aaron Rolloff" wrote in message
...
Let me start by saying that I have read the Knowledge Base article #211769,
in addition to dozens of other posts regarding row insertion errors, but have
yet to find a solution that fixes this problem for me.

I am receiving the "To prevent possible loss of data, Microsoft Office Excel
cannot shift nonblank cells off the worksheet." error when I try to
programmatically insert a range via VBA macro:
Worksheet.Range("MyRange").Select
Worksheet.Rows.Insert (xlShiftDown)

Here are some additional details:
. I am working with Windows XP Professional & Excel 2003 (11.8302.8221),
both w/SP3
. I am able to manually perform the desired insert at design time, but
cannot do the same when I call the macro from a compiled DLL or the Visual
Studio 2005 IDE.
. My worksheet contains no comments, objects, or merged cells.
o <F5 [Special...] 'Comments' produces a "no cells were found" message
o <F5 [Special...] 'Objects' produces a "no objects found" message
. <ctrl<end places the cursor in the last cell used in my worksheet (K3)
o I have deleted all unused rows & columns in the worksheet & saved, to no
avail.
. The named range I am selecting is a single row that spans the entire width
of my used area (A-K3).

My original worksheet was far more complex, but I have gone so far as to
start with a completely new worksheet and the 3 empty rows that I am trying
to populate programmatically, ensuring that there are no merged cells or
other objects n the document, yet I still receive the error.

Can anyone provide additional suggestions/assistance??

Thank you in advance for any help,
Aaron




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Programmatic row insertion error; KB211769 no help


We have a winner!


You forgot the "Ding, ding, ding, ding!" part ;-)

I'm happy to hear that your problem was fixed.

Bernie

PS I have contacted MS to suggest changes to that KB article.


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
programmatic conversion of XLSX into XLS Nataliya Yevdoshenko Excel Programming 1 December 4th 07 04:23 PM
Programmatic Hiding [email protected] Excel Discussion (Misc queries) 2 September 29th 07 01:13 PM
Programmatic export to CSV lucidr Excel Programming 6 July 25th 06 04:43 PM
programmatic advanced filter jmcfadyen Excel Programming 2 May 24th 06 10:11 AM
Programmatic updates ozibryan[_2_] Excel Programming 0 April 6th 06 11:12 AM


All times are GMT +1. The time now is 08:41 PM.

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

About Us

"It's about Microsoft Excel"