+ Reply to Thread
Results 1 to 4 of 4

VBA Macro to Clear Named Cell Contents

  1. #1

    VBA Macro to Clear Named Cell Contents

    I have a workbook with approx. 30 named cells. They all start with
    "clr_". I'm looking for some script that would look for all named cells
    beginning with "clr_" and then go through to delete the content of that
    named cell. for example "clr_projectname" would have the words "my
    project name" and i would like the script to go through and delete the
    words "my project name" from the cell and then go through looking for
    the next name beginning with "clr_" and delete the contents of that
    cell. HELPPPPPP PLZ.


  2. #2
    onceuponatime
    Guest

    Re: VBA Macro to Clear Named Cell Contents

    Try this, just drop this into VBA

    Sub RemoveRange
    Dim nm As Name

    For Each nm In ActiveWorkbook.Names
    Debug.Print nm.Name & " refers to " & nm.RefersTo
    If InStr(1, nm.Name, "clr_") > 0 Then
    Range(nm.Name).ClearContents
    End If
    Next nm

    End Sub


  3. #3
    Bob Phillips
    Guest

    Re: VBA Macro to Clear Named Cell Contents

    Dim nme As Name

    For Each nme In ActiveWorkbook.Names
    If Left(nme.Name, 4) = "clr_" Then
    Range(nme.Name).ClearContents
    End If
    Next nme


    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    <[email protected]> wrote in message
    news:[email protected]...
    > I have a workbook with approx. 30 named cells. They all start with
    > "clr_". I'm looking for some script that would look for all named cells
    > beginning with "clr_" and then go through to delete the content of that
    > named cell. for example "clr_projectname" would have the words "my
    > project name" and i would like the script to go through and delete the
    > words "my project name" from the cell and then go through looking for
    > the next name beginning with "clr_" and delete the contents of that
    > cell. HELPPPPPP PLZ.
    >




  4. #4
    Dave Peterson
    Guest

    Re: VBA Macro to Clear Named Cell Contents

    You have another reply in .misc.

    [email protected] wrote:
    >
    > I have a workbook with approx. 30 named cells. They all start with
    > "clr_". I'm looking for some script that would look for all named cells
    > beginning with "clr_" and then go through to delete the content of that
    > named cell. for example "clr_projectname" would have the words "my
    > project name" and i would like the script to go through and delete the
    > words "my project name" from the cell and then go through looking for
    > the next name beginning with "clr_" and delete the contents of that
    > cell. HELPPPPPP PLZ.


    --

    Dave Peterson

+ 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