ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How to use variable in reference (https://www.excelbanter.com/excel-worksheet-functions/37436-how-use-variable-reference.html)

Ming

How to use variable in reference
 
Hello,

I am wondering if anyone can help me on the use of variable in reference.

As an example, A22 refers to a cell. how can I replace 22 with a variable,
say bb? In this way, I can write a function like SUM(A1:A22) with
SUM(A1:Abb). I need this because I have a lot of exl file. In each file, the
range of sum is different. One
is from A1:A22 while another from A1:A77.

Thanks,


Roger Govier

Try
=SUM(A1:INDIRECT("A"&B1))
Where B1 holds your variable e.g. 22

--
Regards
Roger Govier
"Ming" wrote in message
...
Hello,

I am wondering if anyone can help me on the use of variable in reference.

As an example, A22 refers to a cell. how can I replace 22 with a variable,
say bb? In this way, I can write a function like SUM(A1:A22) with
SUM(A1:Abb). I need this because I have a lot of exl file. In each file,
the
range of sum is different. One
is from A1:A22 while another from A1:A77.

Thanks,




Bob Phillips

=SUM(INDIRECT("A1:A"&B1)

where B1 holds that value

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ming" wrote in message
...
Hello,

I am wondering if anyone can help me on the use of variable in reference.

As an example, A22 refers to a cell. how can I replace 22 with a variable,
say bb? In this way, I can write a function like SUM(A1:A22) with
SUM(A1:Abb). I need this because I have a lot of exl file. In each file,

the
range of sum is different. One
is from A1:A22 while another from A1:A77.

Thanks,





All times are GMT +1. The time now is 01:48 AM.

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