Loop and delete

S

staeri

I have the following code to loop through the cells in AZ:

Dim myRange As Range
Dim myCell As Range

With ActiveSheet
Set myRange = Range("AZ14:AZ33")
End With

For Each myCell In myRange.Cells
If myCell.Value = lstObj.Text Then
myCell.Value = ""

'Here I want to delete the values in cell J to BB!!!
End If
Next myCell

Now it deletes the values in myCell but I want to change this to delete
the values in the cells J to BB. How can this be done?

I'm very grateful for fast response.

Regards,

S
 
B

Bernie Deitrick

S,

Cells(myCell.Row,"J").Resize(1,19).ClearContents

Or

Range(Cells(myCell.Row,"J"), Cells(myCell.Row,"BB")).ClearContents

HTH,
Bernie
MS Excel MVP
 
B

Bernie Deitrick

Oops, I counted to AB, not BB:

Cells(myCell.Row,"J").Resize(1,45).ClearContents

HTH,
Bernie
MS Excel MVP
 

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

Top