Thread: Range names
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Range names

Hi Dean,

If I have named a cell, can I later edit that name?


Yes

If so, will the cells that depend on it pick up the revised name?


No, the formulae will be broken. They can, however, be repaired.

For example, if formulae exist which depend on the names commencing in
'project.a' which are changed to corresponding names commencing in
'phase.1', the resultant broken formulae could be repaired with something
like:

'==================
Public Sub RepairBrokenFormulae()
Dim rng As Range
Dim rcell As Range
Dim sStr As String

On Error Resume Next
Set rng = Cells.SpecialCells(xlCellTypeFormulas, xlErrors)
On Error GoTo 0

For Each rcell In rng.Cells
rcell.Formula = Application.Substitute(rcell.Formula, "project.a",
"phase.1")
Next

End Sub
'<<==================

If the answer to the first question is yes, is there a way to change say,
every range name, that currently starts with "project.a" and, say,
replace that beginning with "phase.1"?


Yes, try something like:

'==================
Public Sub EditNames()
Dim nm As Name
For Each nm In ActiveWorkbook.Names
If nm.Name Like "project.a*" Then
ActiveWorkbook.Names(nm.Name).Name = _
Application.Substitute(nm.Name, "project.a", "phase.1")
End If
Next nm

End Sub

'<<==================


If I go to a range named cell and perform edit-clear-all, will the range
name also be eliminated?


No, clearing the constituent cells of a named range does not delete the
range name.


---
Regards,
Norman



"Dean" wrote in message
...
Folks,

Kindly, answer whichever you can, even if you can't answer all of these:

If I have named a cell, can I later edit that name? If so, will the cells
that depend on it pick up the revised name?

If the answer to the first question is yes, is there a way to change say,
every range name, that currently starts with "project.a" and, say,
replace that beginning with "phase.1"?

Also, if I name an independent cell after another dependent cell's
equation already refers to it, how do I get the dependent cell equation to
show the range name in its equation? If I must edit the equation, is
there some shortcut that would minimize the number of keystrokes involved?

If I go to a range named cell and perform edit-clear-all, will the range
name also be eliminated?

Kindly do not recommend any outside provider add-ins, to do any of the
above, as they tend to freak my bosses out.

Thanks very much!
Dean