Forum Discussion

drw0ng's avatar
drw0ng
Copper Contributor
Jul 14, 2021
Solved

clear cells after a certain row

Hi I am trying to write a macro where it reads in a number from the excel sheet (this number may change) and after clears all rows in the sheet after that number.    In the Excel below, the number ...
  • HansVogelaar's avatar
    Jul 14, 2021

    drw0ng 

    Try this:

    Sub DeleteTest()
        Dim r As Long
        r = Val(Range("Q5").Value)
        If r < 0 Then
            Beep
        Else
            Range("A" & r + 1 & ":I1048576").Clear
        End If
    End Sub

Resources