Issue copying and pasting vba

silverxx12

Board Regular
Joined
Jan 23, 2009
Messages
99
Hi

I used to use excel 2003 - upgraded to 2013 and some issues have come up:i used the following code to copy and paste into another workbook but i am getting an error message at the last stage of inserting the copied rows - worked fine in 2003 not sure what is wrong can someone please help boss is driving me mad :(
!!

This is the code:

Code:
    Rows("2:2").Select                                                 (copying the data from another temp file)    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    End If
    
   
   'open file'
          
    Application.Workbooks.Open("C:.xls").Activate  ( this open the workbook i need to insert copied cells into)
    
   'remove autofilter'
   
    If ActiveSheet.AutoFilterMode = True Then
    ActiveSheet.AutoFilterMode = False
    
    End If
    
    'go to last row'
    
    If Range("b2").Value = "" Then
     Rows("2:2").Select
     Selection.Insert Shift:=xlDown
    Else
    ActiveWindow.FreezePanes = False
    Rows("2:2").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).EntireRow.Select
    Selection.Insert Shift:=xlDown
    End If

Im getting some sort of run time error 1004 - saying insert method of range class failed

Please can someone help i'm sure if simple just havent got my head round 2013 yet :(

Regards

Silver
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi

I used to use excel 2003 - upgraded to 2013 and some issues have come up:i used the following code to copy and paste into another workbook but i am getting an error message at the last stage of inserting the copied rows - worked fine in 2003 not sure what is wrong can someone please help boss is driving me mad :(
!!

This is the code:

Code:
    Rows("2:2").Select                                                 (copying the data from another temp file)    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    End If
    
   
   'open file'
          
    Application.Workbooks.Open("C:.xls").Activate  ( this open the workbook i need to insert copied cells into)
    
   'remove autofilter'
   
    If ActiveSheet.AutoFilterMode = True Then
    ActiveSheet.AutoFilterMode = False
    
    End If
    
    'go to last row'
    
    If Range("b2").Value = "" Then
     Rows("2:2").Select
     Selection.Insert Shift:=xlDown
    Else
    ActiveWindow.FreezePanes = False
    Rows("2:2").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(1, 0).EntireRow.Select
    Selection.Insert Shift:=xlDown
    End If

Im getting some sort of run time error 1004 - saying insert method of range class failed

Please can someone help i'm sure if simple just havent got my head round 2013 yet :(

Regards

Silver

Can anyone please reply this isn't so complicated ??
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,580
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top