Step through this code with F8 and hover over "nName.Name" to ensure the
names matches the pattern
Sub DeleteNames()
Dim nName As Name
For Each nName In ThisWorkbook.Name
If nName.Name Like "fnd_gfm*" _
Then nName.Delete
Next nName
End Sub
--
Regards
Dave Hawley
www.ozgrid.com
"Simon" <(E-Mail Removed)> wrote in message
news:B0BA3020-CFC6-44B4-88B3-(E-Mail Removed)...
> Thanks Lynn
> I have tried this but it doesnt seem to work.
> The code runs OK, but names are still there.
>
> "B Lynn B" wrote:
>
>> I just stole my earlier snippet from something I had working in a
>> particular
>> situation that suited my own purpose. But after looking a little closer,
>> it
>> would be better and more flexible like this...
>>
>> Dim myName as Name
>> Dim wb as Workbook
>> Set wb = Workbooks("WorkbookToLookIn.xls") '(or whatever yours is
>> named)
>>
>> For Each myName In wb.Names
>> If Left(myName.Name, 8) = "fnd_gfm_" Then
>> MyName.Delete
>> End if
>> Next
>>
>>
>>
>> "B Lynn B" wrote:
>>
>> > Dim myName as String
>> >
>> > For Each myName In ActiveWorkbook.Names
>> > If Left(myName.Name, 8) = "fnd_gfm_" Then
>> > ActiveWorkbook.Names(myName).Delete
>> > End if
>> > Next
>> >
>> > adjust as needed if not active workbook...
>> >
>> >
>> > "Simon" wrote:
>> >
>> > > Hi
>> > > I have a macro that imports data from a text file and creates a new
>> > > range
>> > > name every time.
>> > > fnd_gfm_1
>> > > I need some code to delete this range name if it exists.
>> > > Note that the 1 can change depending on how many times the macro has
>> > > run, so
>> > > the code needs to delete fnd_gfm_*
>> > >
>> > > Any help is much appreciated
>> > > Thanks
>> > > Simon