Clear column and row

32,421

Solution 1

This should do the trick!

Range("A21:J200").Clear

Thumbs up to Chris for teaching me a new method!

Solution 2

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.

Share:
32,421
Admin
Author by

Admin

Updated on July 07, 2020

Comments

  • Admin
    Admin almost 4 years

    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