using cell names in vb code

  • Thread starter Thread starter bbxrider
  • Start date Start date
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??????
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top