![]() |
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! |
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! |
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!! |
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!! |
clearing the contents of specified cells
you're right! i had a typo!
thanks so much!!! |
clearing the contents of specified cells
you're right! i had a typo!
thanks so much!!! |
All times are GMT +1. The time now is 07:21 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com