19

I have a cell (Ok there's a bunch but I'm just looking at one now) named "Classes". It's "C10" by Excel's grid notation.

My code works perfectly when I reference the cell as

Range("C10") = "Value"

But when I use

Classes = "Value"

It just does nothing.

So, what's the correct way to reference a named cell by its name?

Jon Crowell
  • 21,695
  • 14
  • 89
  • 110
StolenKitten
  • 611
  • 3
  • 6
  • 12

2 Answers2

36

You replace the address with the named range's name:

Range("Classes") = "Value"
Jon Crowell
  • 21,695
  • 14
  • 89
  • 110
26

You can use the square bracket shorthand for referencing ranges:

[Classes] = "Value"

So you can save on Range and "", and it also looks better (square brackets look a bit like a cell). You can also use [C10] = "Value"

robotik
  • 1,837
  • 1
  • 20
  • 26