using cell names in vb code

B

bbxrider

excel 2000
trying to reference changed cells by their cell name in a case statement
with no luck
code is something like this, have tried target.range, target.name, etc
can't seem to find the right combination of target as and select case

Sub Worksheet_Change(ByVal Target As Excel.Range)
Select Case Target.Range
Case Target.Range("cellName1"), Target.Range("cellName2"), etc
or
Select Case Target.name
Case Target.name("cellName1"), Target.name("cellName2"), etc

i'm thinking there is some way to do this, yes??????
 
B

Bob Umlas

Try this:
Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error Resume Next 'in case target does NOT have a name!
Select Case Target.Name.Name 'yes, .Name.Name!
Case "CellName1", "CellName2"
.....
Case "MyName3"
...
End Select
End Sub

Bob Umlas
Excel MVP
 
B

bbxrider

name.name is bizare but works, thanks a lot

Bob Umlas said:
Try this:
Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error Resume Next 'in case target does NOT have a name!
Select Case Target.Name.Name 'yes, .Name.Name!
Case "CellName1", "CellName2"
.....
Case "MyName3"
...
End Select
End Sub

Bob Umlas
Excel MVP
 
Top