ExcelArtist2019
New Member
- Joined
- Nov 29, 2019
- Messages
- 2
- Office Version
- 2016
- Platform
- Windows
Attempting to modify a MACRO that deletes rows based on input box date < criteria - that works great! Now need to just clear contents of cell two cells to the left and not an entire row. Not sure what needs to be done on this line: ActiveCell.Offset(0, -2).ClearContents - not working. Dates and row counts continually change/increase. Including screen shot of sample data.
Sub FifthSCCMacro()
'
' FifthSCCMacro Macro
' Clear cell contents Add-on CLINs two cells to the left (Column J) based on all end dates older then date entered in input box on column L data
'
Dim LastRow As Long, x As Long
Dim resp
resp = InputBox("Enter value to clear", "ClearContents")
If resp = "" Then Exit Sub
MsgBox ("Are you sure you want to clear add-ons " & resp)
LastRow = Cells(Cells.Rows.Count, "L").End(xlUp).Row
If IsDate(resp) Then
resp = CDate(resp)
End If
For x = LastRow To 1 Step -1
If IsDate(resp) Then
If Cells(x, "L").Value < resp Then
ActiveCell.Offset(0, -2).ClearContents
End If
End If
If Not IsDate(resp) Then
If UCase(Cells(x, "L").Value) < UCase(resp) Then
ActiveCell.Offset(0, -2).ClearContents
End If
End If
Next
End Sub
Sub FifthSCCMacro()
'
' FifthSCCMacro Macro
' Clear cell contents Add-on CLINs two cells to the left (Column J) based on all end dates older then date entered in input box on column L data
'
Dim LastRow As Long, x As Long
Dim resp
resp = InputBox("Enter value to clear", "ClearContents")
If resp = "" Then Exit Sub
MsgBox ("Are you sure you want to clear add-ons " & resp)
LastRow = Cells(Cells.Rows.Count, "L").End(xlUp).Row
If IsDate(resp) Then
resp = CDate(resp)
End If
For x = LastRow To 1 Step -1
If IsDate(resp) Then
If Cells(x, "L").Value < resp Then
ActiveCell.Offset(0, -2).ClearContents
End If
End If
If Not IsDate(resp) Then
If UCase(Cells(x, "L").Value) < UCase(resp) Then
ActiveCell.Offset(0, -2).ClearContents
End If
End If
Next
End Sub