Forum Discussion
drw0ng
Jul 14, 2021Copper Contributor
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 ...
- Jul 14, 2021
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 
HansVogelaar
Jul 14, 2021MVP
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- drw0ngJul 14, 2021Copper ContributorThank you this worked perfectly!
I really appreciate your help Hans 🙂