Range selection

  • Thread starter Thread starter daniroy
  • Start date Start date
D

daniroy

Hello everybody and many thanks for the help,
I guess it is pretty straightforward if you know it but I dont.

I have a list of row and so
For i = 1 to 600
and then an If expression and after then I want a range of two cells to
be deleted
I am trying this writing but obviously not working, any suggestions?
Worksheets("ESX").Range("K" & i & ":L" & i).ClearContents

What I want is Cells columns K and L for line i to be deleted but at
the same time, not first K then L but altogether, that is why I am
using Range("K" & i & ":L" & i).
But I am not putting the " and & at the right place, can you please
help?

Thanks in advance!
DR
 
I just through an example together which works. Just change it to suit.

Sub test()

Dim i As Integer

For i = 1 To 40
If Range("A" & i).Value = 1 Then
Range("B" & i & ":C" & i).ClearContents
End If
Next i

End Sub

Hope it helps
 
Your code works fine for me. However, you could just as easily use:

Worksheets("ESX").Cells(i, "K").Resize(1, 2).ClearContents
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top