Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PivotChart - Small question Helen Excel Discussion (Misc queries) 2 January 28th 09 04:25 PM
Small,Frequency question Sorority Girl Excel Discussion (Misc queries) 1 May 19th 08 04:41 AM
One small question... VIVEKMANE Excel Discussion (Misc queries) 3 November 8th 07 02:42 PM
Excel to Outlook Small Question twogoodtwo Excel Programming 4 August 6th 04 04:41 PM
Quick question on a small Macro attached! aiyer[_23_] Excel Programming 1 May 13th 04 10:44 AM


All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"