VBA Macro to Clear Named Cell Contents

  • Thread starter Thread starter marajr
  • Start date Start date
M

marajr

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.
 
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
 
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)
 
You have another reply in .misc.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top