ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range selection (https://www.excelbanter.com/excel-programming/367521-range-selection.html)

[email protected]

Range selection
 
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


Graham Whitehead

Range selection
 
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

wrote in message
oups.com...
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




[email protected]

Range selection
 
Thats just perfect many thanks!
Graham Whitehead a écrit :

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

wrote in message
oups.com...
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



JE McGimpsey

Range selection
 
Your code works fine for me. However, you could just as easily use:

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



In article .com,
wrote:

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



All times are GMT +1. The time now is 03:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com