Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? | Excel Discussion (Misc queries) | |||
How do I execute a macro based on the value of a cell in Excel? | Excel Discussion (Misc queries) | |||
Possible Lookup Table | Excel Worksheet Functions | |||
Copy cell format to cell on another worksht and update automatical | Excel Worksheet Functions | |||
GET.CELL | Excel Worksheet Functions |