msquared99
04-05-2012, 02:49 PM
OK, I'm new at this. I have several reports that I run. I have some code that finds the last empty row in the sheet. I want to use this value to have all the rows from this row on to be deleted. The rows of data will vary in the numbers of rows it has.
Here is the code that finds the first row with no data:
lastRow = Worksheets("M3").Range("B" & Rows.Count).End(xlUp).Row + 1
I want this to use the value of lastRow and delete or clear the contents to the end of the workbook:
Worksheets("M3").Range(lastRow).End(xlDown).Select.ClearContents
Workbook 1 the data ends on say row 44, delete or clear from row 45 to the bottom of the workbook.
Workbook 2 may have the data end on row 100, it varies in each workbook.
Thanks for the help.
Mike
Here is the code that finds the first row with no data:
lastRow = Worksheets("M3").Range("B" & Rows.Count).End(xlUp).Row + 1
I want this to use the value of lastRow and delete or clear the contents to the end of the workbook:
Worksheets("M3").Range(lastRow).End(xlDown).Select.ClearContents
Workbook 1 the data ends on say row 44, delete or clear from row 45 to the bottom of the workbook.
Workbook 2 may have the data end on row 100, it varies in each workbook.
Thanks for the help.
Mike