Macro stops running

Misca

Well-known Member
Joined
Aug 12, 2009
Messages
1,749
Office Version
  1. 365
Platform
  1. Windows
I've got a simple macro that makes copies of the original table 10 rows below the last table. Once it has copied the table it takes a same sized formula table and copies it next to the new table. Or so it should but the macro stops running right after copying the first table and I can't figure out why.

Here's my code:
Code:
Sub CopyTable()
 
Dim Rng As Range
Dim c As Range
 
With Sheet1

'Original table:
    Set Rng = .Range("A68:AC126")
 
'Destination= 10 rows below the last table
    Set c = .Cells(.Rows.Count, 1).End(xlUp).Offset(10)
        
'Copies the original table:
                With Rng
                    .Copy Destination:=c    '.Resize(.Rows.Count, .Columns.Count)
                End With
      
'Copies the formula table:
                With Rng.Offset(0, 35)
                    .Copy Destination:=c.Offset(0, 35)
                End With

End With
 
End Sub
I'm using Excel 2003 and so far there's only two tables on the page so there should be plenty of rows left to pile up the tables.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
The macro is supposed to run only once at a time and the user is supposed to fire the macro whenever he needs another table.

The problem is the macro stops halfway through but I can't figure out why it does that.
 
Upvote 0
I have added a commandbutton to run the macro, and copied up to 29 tables with no problem.

The code works just fine. I am using Excel 2007, but don't think this is the reason.

It won't harm double checking the code in your post is the same as the one in the workbook.
 
Upvote 0

Forum statistics

Threads
1,215,632
Messages
6,125,908
Members
449,273
Latest member
mrcsbenson

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