Reputation: 39
Need vba code to Clear column from A to J and row from 21 to 200. Below code is clearing the column till end, need to delete till column J
Function ClearSummary()
Const TestName_Col = "B"
Const FirstRow_Num = "21"
MaxRowNumber = Range(TestName_Col & "200").End(xlUp).Row
If (MaxRowNumber > FirstRow_Num) Then
'select all rows in range & clear
CellReference = FirstRow_Num & ":" & MaxRowNumber
Rows(CellReference).Select
Selection.ClearContents
Selection.Hyperlinks.Delete
Selection.Font.Underline = xlUnderlineStyleNone
Selection.Font.ColorIndex = 0
End If
End Function
Upvotes: 3
Views: 32819
Reputation: 1104
A spin off of t.thielemans answer for those who do not want to lose things such as formatting or data validation
Range("A21:J200").ClearContents
This will ensure that you keep everything except the current value of the cells selected.
Upvotes: 1
Reputation: 10113
This should do the trick!
Range("A21:J200").Clear
Thumbs up to Chris for teaching me a new method!
Upvotes: 5