Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Run-time error when copying entire row!

Hi
I have the following code:
ActiveSheet.Range("LastLine").Select 'range name
ActiveCell.Offset(-1, 0).EntireRow.Copy
Selection.EntireRow.Insert
Application.CutCopyMode = False
Range("Lastline").Offset(-1, 0).Select

On my lastline i have totals for various columns. So i copy the entire row of the previous row and insert it after the copied row or before the totals row/lastline. I get the following error on the code line 'Selection.EntireRow.Insert'
first "Run-time error '-2147417848 (80010108)':
Method 'Insert' of object 'Range' failed." When i run the debug and press F5 in VBE i get another error "Run-time error '1004' Insert method of Range class failed". Then Excel freezes and have to crash out.
I can't figure out the error, any help will be appreciated.
Many thanks
Kieranz

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Run-time error when copying entire row!

Hi,

Try this method. It worked for me.

With ActiveSheet.Range("LastRow")
.Offset(-1, 0).EntireRow.Copy
.Insert (xlDown)
Application.CutCopyMode = False
.Offset(-1, 0).Select
End With

-Ben
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Run-time error when copying entire row!

On Monday, September 17, 2012 5:03:02 PM UTC+2, Ben McClave wrote:
Hi,



Try this method. It worked for me.



With ActiveSheet.Range("LastRow")

.Offset(-1, 0).EntireRow.Copy

.Insert (xlDown)

Application.CutCopyMode = False

.Offset(-1, 0).Select

End With



-Ben

Ben many thks. Will try that. Although couldn't understand what wrong with my code
K

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Run-time error when copying entire row!

K,

I'm not sure why your code wasn't working. I tried it on my computer and it worked fine. I wonder if you may have the sheet protected. Turning on protection caused your code to break on the same line as you mention in your post.

Ben
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default Run-time error when copying entire row!

Kieranz wrote:

Ben many thks. Will try that. Although couldn't understand what wrong with my code



Nothing is wrong.
It works fine.
However after you insert row, recalculation is triggered and something
else, somewhere else is crashing.

Try you code on empty workbook and check if it works or not. It should.
Try to switch to manual calculation and see if that works in you
application.

Generally using .select is not a good idea.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Run-time error when copying entire row!

On Monday, September 17, 2012 11:48:36 PM UTC+2, witek wrote:
Kieranz wrote:



Ben many thks. Will try that. Although couldn't understand what wrong with my code






Nothing is wrong.

It works fine.

However after you insert row, recalculation is triggered and something

else, somewhere else is crashing.



Try you code on empty workbook and check if it works or not. It should.

Try to switch to manual calculation and see if that works in you

application.



Generally using .select is not a good idea.


Witek and Ben
Yes, i have a protect some where in the code. Thks again K
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
Run time error '4605' while copying excel range as picture in Wor Samirkc Excel Programming 0 July 27th 06 03:45 PM
Copying an entire row smitty24 Excel Programming 2 March 31st 06 05:16 AM
Copying entire row Sylvia[_11_] Excel Programming 1 January 12th 06 03:57 AM
copying entire column Charlie[_8_] Excel Programming 2 September 30th 04 12:50 PM
Macro for copying entire raw Mac[_5_] Excel Programming 3 November 13th 03 03:09 AM


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