PDA

View Full Version : [SOLVED] Clear contents with in a range in Excel through VB



BMD4
07-11-2018, 02:18 PM
Hi,
I am trying to clear contents for column A to D.
I used below statement which worked.


Sheet1.Range("A:D").ClearContents

Now, I have a scenario where in I should not delete value in cell A1.
My range is from A2 till Col A end and Cols B,C and D.
Can anyone suggest how can we get this range cleared
Thanks in advance

p45cal
07-11-2018, 02:58 PM
lr = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row
If lr > 1 Then Sheet1.Range("A2:D" & lr).ClearContents

BMD4
07-11-2018, 07:59 PM
Thank you.This solved my issue.