• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

If value higher than x, clear content

freshtomm

Member
Hi,
i need to modificate the VBA code below to just clear content in colums A:D, not to delete entire row. Is that possible?


Code:
Dim i As Long
  For i = Range("C" & Rows.Count).End(xlUp).Row To 1 Step -1
  If (Range("C" & i).Value <= 2016) Then
  Range("C" & i).EntireRow.delete
  End If
  Next i

Thanks.
 
Hi,

Just replace delete with ClearContents

Code:
Sub test()
Dim i As Long
  For i = Range("C" & Rows.Count).End(xlUp).Row To 1 Step -1
  If (Range("C" & i).Value <= 2016) Then
  Range("C" & i).EntireRow.ClearContents
      End If
  Next i
End Sub

Regards,
 
Hi,

Remove the .EnitreRow
And add column D

Code:
Sub test()
Dim i As Long
  For i = Range("C" & Rows.Count).End(xlUp).Row To 1 Step -1
  If (Range("C" & i).Value <= 2016) Then
  Range("C" & i).ClearContents
  Range("D" & i).ClearContents
  End If
  Next i
End Sub

Regards,
 
Back
Top