I am trying to write some code that will count the number of total rows in a particuar sheet, and then delete the data in them, but only for some of the columns.
The counting bit was easy just setting a variable equal to:
UsedRange.Rows.Count
However, when I try to reference a Range wichi includes this variable, it doesn't like it. Here's the code I've written:
As you see, the idea is quite simple, clear the contents, from Cells(3,11) to Cells(TotalRows,13), but this doesn't seem to work.
Help please...
The counting bit was easy just setting a variable equal to:
UsedRange.Rows.Count
However, when I try to reference a Range wichi includes this variable, it doesn't like it. Here's the code I've written:
Code:
TotalRows = Sheets("Costs").UsedRange.Rows.Count
Sheets("Costs").Select
Range(Cells(3,11),Cells(TotalRows,13)).Select
Selection.ClearContents
As you see, the idea is quite simple, clear the contents, from Cells(3,11) to Cells(TotalRows,13), but this doesn't seem to work.
Help please...