ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   a small question (https://www.excelbanter.com/excel-programming/330780-small-question.html)

Jimmy Pop

a small question
 
Hello,
I have the following code to look for a keyword and then clear the
contents of the cells from columns A to E above the specified word..

Sub findkeyword()
Dim cell As Range
Dim myKeyword

myKeyword = "clue"
Set cell = Cells.Find(myKeyword)
If Not cell Is Nothing Then
Range("A4:E" & cell.Row - 1).ClearContents
End If
End Sub

I want to also delete cells F, G, and H located on 2 rows below the
keyword. Can someone help me with that coding?

Thanks,
jimmy.pop


Tom Ogilvy

a small question
 
It isn't clear whether you want the 2 rows below the cell or a single row 2
rows below the cell. This does 2 rows below the cell.

Sub findkeyword()
Dim cell As Range
Dim myKeyword

myKeyword = "clue"
Set cell = Cells.Find(myKeyword)
If Not cell Is Nothing Then
Range("A4:E" & cell.Row - 1).ClearContents
cells(cell.row+1,"F").Resize(2,3).ClearContents
End If
End Sub


cells(cell.Row + 2).Resize(1,3).Clearcontents
would be the single row 2 rows below.

--
Regards,
Tom Ogilvy


"Jimmy Pop" wrote in message
oups.com...
Hello,
I have the following code to look for a keyword and then clear the
contents of the cells from columns A to E above the specified word..

Sub findkeyword()
Dim cell As Range
Dim myKeyword

myKeyword = "clue"
Set cell = Cells.Find(myKeyword)
If Not cell Is Nothing Then
Range("A4:E" & cell.Row - 1).ClearContents
End If
End Sub

I want to also delete cells F, G, and H located on 2 rows below the
keyword. Can someone help me with that coding?

Thanks,
jimmy.pop




Nigel

a small question
 
If I read you right try this additional line

Sub findkeyword()
Dim cell As Range
Dim myKeyword

myKeyword = "clue"
Set cell = Cells.Find(myKeyword)
If Not cell Is Nothing Then
Range("A4:E" & cell.Row - 1).ClearContents
Range(Cells(cell.row + 2, 6),cells(cell.row+2,8)).clearcontents
End If
End Sub

--
Cheers
Nigel



"Jimmy Pop" wrote in message
oups.com...
Hello,
I have the following code to look for a keyword and then clear the
contents of the cells from columns A to E above the specified word..

Sub findkeyword()
Dim cell As Range
Dim myKeyword

myKeyword = "clue"
Set cell = Cells.Find(myKeyword)
If Not cell Is Nothing Then
Range("A4:E" & cell.Row - 1).ClearContents
End If
End Sub

I want to also delete cells F, G, and H located on 2 rows below the
keyword. Can someone help me with that coding?

Thanks,
jimmy.pop





All times are GMT +1. The time now is 05:14 PM.

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