+ Reply to Thread
Results 1 to 6 of 6

clearing the contents of specified cells

  1. #1
    Jimmy Pop
    Guest

    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. #2
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #3
    Jimmy Pop
    Guest

    Re: 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. #4
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #5
    Jimmy Pop
    Guest

    Re: clearing the contents of specified cells

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


  6. #6
    Jimmy Pop
    Guest

    Re: clearing the contents of specified cells

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


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1