Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
reaa
 
Posts: n/a
Default VBA Excel Macro to delete contents in named cell

I have several named cells in an MS excel workbook, starting with the
word "clr_". I'm looking for a looping statement that would look for
how many names there are in the workbook beginning with "clr_" and then
go through a loooping statement to delete the contents in that named
cell. For example, clr_projectname might have the words "My Project"
and i want the words "my project" to be deleted from the cell. I have
about 30 variables to be deleted. Anyone's help would be appreciated!

  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default VBA Excel Macro to delete contents in named cell

Maybe something like:

Option Explicit
Sub testme()

Dim myName As Name

For Each myName In ActiveWorkbook.Names
If LCase(myName.Name) Like "clr_*" _
Or LCase(myName.Name) Like "*!clr_*" Then
On Error Resume Next
myName.RefersToRange.ClearContents
On Error GoTo 0
End If
Next myName

End Sub


clr_* will catch the workbook level names
*!clr_* will catch the worksheet level names

The on error stuff is there just in case that name doesn't refer to a range.

reaa wrote:

I have several named cells in an MS excel workbook, starting with the
word "clr_". I'm looking for a looping statement that would look for
how many names there are in the workbook beginning with "clr_" and then
go through a loooping statement to delete the contents in that named
cell. For example, clr_projectname might have the words "My Project"
and i want the words "my project" to be deleted from the cell. I have
about 30 variables to be deleted. Anyone's help would be appreciated!


--

Dave Peterson
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
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
How do I execute a macro based on the value of a cell in Excel? brettopp Excel Discussion (Misc queries) 12 June 17th 06 01:27 AM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 08:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"