Hi Tony
Thanks for the help, much appreciated
I need the folowing change
I need the data cleared on all the sheets, except the last two sheets-all criteria the same as before
I have tried to do this myself, but it comes up with a compile error when activating the macro-see changes to code & asttachment
RangeToClear = FirstColumnToClear + Format(FirstRowToClear) RangeToClear = RangeToClear + ":"
HTML Code:Sub HowardsClearRoutine() Const FirstRowToClear = 4 Const FirstColumnToClear = "A" Const LastColumnToClear = "D" Const TotalColumn = "A" Dim i As Long For i = 1 To Worksheets.Count - 2 Dim LastRowToClear As Integer Dim RangeToClear As String Dim LocationOfTotal As Range Dim Sht As Worksheet For Each Sht In MyBook.Worksheets ' Find the row where the word "Total" is in column A, and clearthe contents of rows ' FirstRowToClear through LastRowToClear for columns FirstColumnToClear thru LastColumnToClear Set Sht = ActiveSheet ' You may want to be a little more specific about this! Set LocationOfTotal = Sht.Columns(TotalColumn).Find("Total") ' Last row to clear is the row BEFORE the Total LastRowToClear = LocationOfTotal.Row - 1 ' Now construct the range which we will be clearing RangeToClear = FirstColumnToClear + Format(FirstRowToClear) RangeToClear = RangeToClear + ":" RangeToClear = RangeToClear + LastColumnToClear + Format(LastRowToClear) ' Do we want to clear the contents, or delete the cells? This example simply clears the contents Sht.Range(RangeToClear).ClearContents Next i End Sub
I have tried to amend the code to ignore the last two sheets when clearing data




Reply With Quote
Bookmarks