Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
PivotChart - Small question | Excel Discussion (Misc queries) | |||
Small,Frequency question | Excel Discussion (Misc queries) | |||
One small question... | Excel Discussion (Misc queries) | |||
Excel to Outlook Small Question | Excel Programming | |||
Quick question on a small Macro attached! | Excel Programming |