ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Referencing cells safely (https://www.excelbanter.com/excel-programming/383981-referencing-cells-safely.html)

David G[_4_]

Referencing cells safely
 
Hello,

I am trying to find the best way to refer to cells in a large range
based on the column they are under. The number and order of columns in
the range is changed frequently and I want to make sure that the
reference always works, so I can't simply hard-code a column number.
Right now, I determine the column that I am interested in by providing
a Name to the column header and finding the column number from the
Named cell. The problem with this is that the number of named cells is
getting quite large and confusing.
Does anyone know any better ways of doing this?

Thanks,
David


Zack Barresse

Referencing cells safely
 
If the cell will have consistent data, you could think about using the Find
feature and set the cell(s) to a range. Or, if you have consistent
column/row headers, you can find those and use the Column and Row numbers
from each respectively (using the Cells method).

HTH

--
Regards,
Zack Barresse, aka firefytr
MsgBox "fire" & "fytr" & Chr(64) & "vba" & "express" & Chr(46) & "com"



"David G" wrote in message
ups.com...
Hello,

I am trying to find the best way to refer to cells in a large range
based on the column they are under. The number and order of columns in
the range is changed frequently and I want to make sure that the
reference always works, so I can't simply hard-code a column number.
Right now, I determine the column that I am interested in by providing
a Name to the column header and finding the column number from the
Named cell. The problem with this is that the number of named cells is
getting quite large and confusing.
Does anyone know any better ways of doing this?

Thanks,
David



David G[_4_]

Referencing cells safely
 
Thanks for your suggestion. Unfortunately, the data in any cell is
subject to change, including column headers. I think it is safe to
assume, though, that the meaning of columns does not change, even if
the header does. For example, if the header is changed from "Name" to
"ID", the column still represents the same data.
I must admit, I don't know exactly what kind of solution I am looking
for. I'm just looking for suggestions to see if any would fit the
requirements for this task.

On Feb 26, 4:43 pm, "Zack Barresse" wrote:
If the cell will have consistent data, you could think about using the Find
feature and set the cell(s) to a range. Or, if you have consistent
column/row headers, you can find those and use the Column and Row numbers
from each respectively (using the Cells method).

HTH

--
Regards,
Zack Barresse, aka firefytr
MsgBox "fire" & "fytr" & Chr(64) & "vba" & "express" & Chr(46) & "com"

"David G" wrote in message

ups.com...

Hello,


I am trying to find the best way to refer to cells in a large range
based on the column they are under. The number and order of columns in
the range is changed frequently and I want to make sure that the
reference always works, so I can't simply hard-code a column number.
Right now, I determine the column that I am interested in by providing
a Name to the column header and finding the column number from the
Named cell. The problem with this is that the number of named cells is
getting quite large and confusing.
Does anyone know any better ways of doing this?


Thanks,
David




Zack Barresse

Referencing cells safely
 
A Name will work then, yes. As long as you have something that will
identify that and be constant. Whether that be a value, formula, partial
text, after a certain position/value, etc. Whatever you can logically use
to deduce the location. If you do not have a unique criterion, create one.

Does that answer your question?

--
Regards,
Zack Barresse, aka firefytr
MsgBox "fire" & "fytr" & Chr(64) & "vba" & "express" & Chr(46) & "com"



"David G" wrote in message
oups.com...
Thanks for your suggestion. Unfortunately, the data in any cell is
subject to change, including column headers. I think it is safe to
assume, though, that the meaning of columns does not change, even if
the header does. For example, if the header is changed from "Name" to
"ID", the column still represents the same data.
I must admit, I don't know exactly what kind of solution I am looking
for. I'm just looking for suggestions to see if any would fit the
requirements for this task.

On Feb 26, 4:43 pm, "Zack Barresse" wrote:
If the cell will have consistent data, you could think about using the
Find
feature and set the cell(s) to a range. Or, if you have consistent
column/row headers, you can find those and use the Column and Row numbers
from each respectively (using the Cells method).

HTH

--
Regards,
Zack Barresse, aka firefytr
MsgBox "fire" & "fytr" & Chr(64) & "vba" & "express" & Chr(46) & "com"

"David G" wrote in message

ups.com...

Hello,


I am trying to find the best way to refer to cells in a large range
based on the column they are under. The number and order of columns in
the range is changed frequently and I want to make sure that the
reference always works, so I can't simply hard-code a column number.
Right now, I determine the column that I am interested in by providing
a Name to the column header and finding the column number from the
Named cell. The problem with this is that the number of named cells is
getting quite large and confusing.
Does anyone know any better ways of doing this?


Thanks,
David





David G[_4_]

Referencing cells safely
 
Yes, it does. Thank you.

On Feb 28, 4:08 pm, "Zack Barresse" wrote:
A Name will work then, yes. As long as you have something that will
identify that and be constant. Whether that be a value, formula, partial
text, after a certain position/value, etc. Whatever you can logically use
to deduce the location. If you do not have a unique criterion, create one.

Does that answer your question?

--
Regards,
Zack Barresse, aka firefytr
MsgBox "fire" & "fytr" & Chr(64) & "vba" & "express" & Chr(46) & "com"

"David G" wrote in message

oups.com...

Thanks for your suggestion. Unfortunately, the data in any cell is
subject to change, including column headers. I think it is safe to
assume, though, that the meaning of columns does not change, even if
the header does. For example, if the header is changed from "Name" to
"ID", the column still represents the same data.
I must admit, I don't know exactly what kind of solution I am looking
for. I'm just looking for suggestions to see if any would fit the
requirements for this task.


On Feb 26, 4:43 pm, "Zack Barresse" wrote:
If the cell will have consistent data, you could think about using the
Find
feature and set the cell(s) to a range. Or, if you have consistent
column/row headers, you can find those and use the Column and Row numbers
from each respectively (using the Cells method).


HTH


--
Regards,
Zack Barresse, aka firefytr
MsgBox "fire" & "fytr" & Chr(64) & "vba" & "express" & Chr(46) & "com"


"David G" wrote in message


roups.com...


Hello,


I am trying to find the best way to refer to cells in a large range
based on the column they are under. The number and order of columns in
the range is changed frequently and I want to make sure that the
reference always works, so I can't simply hard-code a column number.
Right now, I determine the column that I am interested in by providing
a Name to the column header and finding the column number from the
Named cell. The problem with this is that the number of named cells is
getting quite large and confusing.
Does anyone know any better ways of doing this?


Thanks,
David





All times are GMT +1. The time now is 10:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com