Out of Memory error in VBA macro

ExcelEric

New Member
Joined
Sep 8, 2015
Messages
2
I know there are several posts about this problem on this forum, but my problem is more confusing because i'm not even dealing with a significant amount of data. All I am trying to do is have a macro dynamically determine the # of rows of data for 1 worksheet and name a range based on that. The current data range only has 6 columns (A:F, it stays static) and 81 rows. Here is the code:

Sub Dyno_Range1()

Dim LastRow As Long

LastRow = Sheet1.Range("A" & Rows.Count).End(xlUp).Row

Sheet1.Range("A7:F" & LastRow).Name = "Data"

End Sub

This code actually works in that the range gets named correctly, but at the "End Sub" it brings back an "Out of Memory" error. I don't get it because LastRow = "81". How can this possibly use up enough memory to cause an Out of Memory error?

Thanks for your help Excel experts!

Eric
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Thanks Joe. I'll review the link and see if I can find anything.

Eric
You are welcome. If you do sort it out, post back with the solution. May help others with a similar problem.
 
Upvote 0
I believe this is an error caused by a Microsoft update. A temporary fix is to close the VBA window and macro should run with no problems.
 
Upvote 0
Fascinating temporary fix. Still frustrating while developing and checking results....
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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