Removing Names

Giordano Bruno

Well-known Member
Joined
Jan 7, 2007
Messages
1,341
I use a program called @RISK and it has the unfortunate habit of adding thirty names to any spreadsheet that is loaded while it is running.

All of the names commence with the word "risk", e.g. RiskRunAfterRecalcMacro.

I need some code that will look a the collection Names in active workbook and delete all names which start with "risk".

Any ideas?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi Giordano,

Try:
Option Explicit

Code:
Sub KillRiskNames()
Dim oName As Name
For Each oName In ActiveWorkbook.Names
    If Left(oName.Name, 4) = "Risk" Then oName.Delete
Next
End Sub

Cheers
 
Upvote 0
HI

Assuming the names are in col A, try these codes

Code:
Sub remove()
x = Cells(Rows.Count, 1).End(xlUp).Row
For a = 1 To x
If Left(Cells(a, 1), 4) = "risk" Then
Cells(a, 1).ClearContents
End If
Next a
End Sub
run the macro. it will clear the cell if it contains risk at the beginning of the string.
ravi
 
Upvote 0
ravishankar,

I'm sorry that my post was unclear. The names are added as named ranges, not text on a worksheet, but thanks for your interest.

Macropod,

Thanks for the code. Works perfectly. It will be very useful in the future also as this is a persistant problem.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top