You are here:

Excel/Referencing Named Cells In VBA



This question is in regards to the post you answered a couple of days ago about setting up the code so that if we were to sort e.g. A1:A50 and a set A1:A5 was moved around, the function would still only work within that defined group.

You had mention named ranges would not work like described above. But what if we assigned each cell a name and referenced it in VBA. Would that work?

How do you reference a named cell with the code you provided in VBA?

ANSWER: Derek,

I tested that Idea.

I named 25 cells with individual names, then sorted them.  The names still referred to the original cell location and was unrelated to the value displayed there in.

If you had some type of value in an adjacent column that would identify the cells and you sorted that column along with the original values so they remained in the same row with each other although which row changes based on the sort, then you could use that column to determine which cells to work with.  

Tom Ogilvy

---------- FOLLOW-UP ----------

QUESTION: So, essentially after having sorted by an adjacent column while keeping the Enabled/Paused values in the same row as the original cells in adjacent column, change the range values in the code (list individually in non contiguous range)to work with that specific sort.

If this is not what you mean, can you forward an example spreadsheet?

Thank you much!



I don't have your email.  The only thing I know about you is the word "Derek"

If you want to send a dummy file indicating which column identifies a group and which column will be changed to Enabled/Paused based on an entry of "????" (refresh my memory on what the key word is - was it Enabled?) in the trigger cell.  

send to

Tom Ogilvy

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Tom Ogilvy


Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]


Extensive experience.

Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2016 All rights reserved.