PDA

View Full Version : Selection Clear Content



paulypau
04-04-2017, 05:43 PM
Hello,

I don't have a lot of experience with macros but I have an issue as the person who develop the macro is unable and we are unable to fix the issue.
The Excel file / Macro was working properly, until there was a company system update and it's not longer working - after reviewing the code I was able to determine that the macro is having issues in this point


Public Sub Clean()
ActiveWorkbook.Worksheets("Review").Activate
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
End Sub

At this point the macro starts calculating and stops and Excel crashes

Logit
04-04-2017, 07:24 PM
The code runs fine here.

This line
Range(Selection, Selection.End(xlDown)).Select selects all the rows from #3 to the bottom of the sheet.
Excel 2007 and newer has 1,045,876 rows. Is it possible selecting all of the rows to the bottom of the worksheet has maxed
out the resources on your system ?

Is it necessary to select all of those rows ? Is the worksheet utilizing all 1,045,876 rows ?

Can you reduce the number of rows the macro is selecting and still accomplish your goal ?

mdmackillop
04-05-2017, 03:43 AM
Why not

ActiveWorkbook.Worksheets("Review").UsedRange.Offset(1).ClearContents