![]() |
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! |
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 |
All times are GMT +1. The time now is 06:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com