Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default clearing the contents of specified cells

i am trying to write a macro the clears the cells from a fixed starting
point to a keyword whose location could change everyday.
i want to clear a range of cells (say a1:g1) and all the rows from the
fixed starting point to the row above the keyword. For some reason i
can't figure what to do. Any help would be appreciated.

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default clearing the contents of specified cells

Hi Jimmy,

Here is a simple macro that gives you must of what you want.

Sub Findit()
Dim cell As Range
Dim myKeyword

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

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jimmy Pop" wrote in message
oups.com...
i am trying to write a macro the clears the cells from a fixed starting
point to a keyword whose location could change everyday.
i want to clear a range of cells (say a1:g1) and all the rows from the
fixed starting point to the row above the keyword. For some reason i
can't figure what to do. Any help would be appreciated.

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default clearing the contents of specified cells

Thanks Bob!
This works great, except it is deleting the final row that has my
"keyword" as well as other data i need. to fix this what do i need to
change?
you can tell that i am very new to the macro world.
Thanks again!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default clearing the contents of specified cells

Are you sure Jimmy, I just tried it again and it kept cells A-G on the
keyword row intact

Sub Findit()
Dim cell As Range
Dim myKeyword

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

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jimmy Pop" wrote in message
oups.com...
Thanks Bob!
This works great, except it is deleting the final row that has my
"keyword" as well as other data i need. to fix this what do i need to
change?
you can tell that i am very new to the macro world.
Thanks again!!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default clearing the contents of specified cells

you're right! i had a typo!
thanks so much!!!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default clearing the contents of specified cells

you're right! i had a typo!
thanks so much!!!

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
Clearing Contents AMANDA Excel Discussion (Misc queries) 2 July 6th 09 05:34 PM
Clearing the Contents of Merged Cells prizm1 New Users to Excel 2 September 10th 05 04:42 AM
Clearing Contents Sean Excel Programming 5 May 6th 05 05:16 PM
Clearing Contents of all "unprotected" Cells. Casey[_12_] Excel Programming 2 August 6th 04 09:40 PM
Clearing the contents of merged cells Doug Glancy Excel Programming 0 April 23rd 04 08:54 PM


All times are GMT +1. The time now is 05:54 AM.

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"