ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping on Cells with $x$y (https://www.excelbanter.com/excel-programming/326144-looping-cells-%24x%24y.html)

D.Parker

Looping on Cells with $x$y
 
Hello. I would like to utilize your expertise again. Is there a way to to
loop through cells that have the form "$B$2", such as "$Bi$j", where i and j
are integers. Is this possible? Is so how, because I tried with i and j type
looping. Thanks again.

D. Parker

Shawn O'Donnell

Looping on Cells with $x$y
 
"D.Parker" wrote:
Hello. I would like to utilize your expertise again. Is there a way to to
loop through cells that have the form "$B$2", such as "$Bi$j", where i and j
are integers.


$Bi$j could be $B2$3, which isn't a well-formed cell address.

What exactly is it that you want to do? There may be ways do what you need
without resorting to building cell addresses out of strings.


Jim Thomlinson[_3_]

Looping on Cells with $x$y
 
$B$2 is a single cell. What is there to loop through. Unless you mean the
range bounded by A1 and B2. if that is the case then

dim rngToSearch as range
dim rngCurrent as range

set rngToSearch = range(activesheet("A1"), activesheet("B2"))
for each rngcurrent in rngToSearch
msgbox rngCurrent.address

next rngCurrent

"D.Parker" wrote:

Hello. I would like to utilize your expertise again. Is there a way to to
loop through cells that have the form "$B$2", such as "$Bi$j", where i and j
are integers. Is this possible? Is so how, because I tried with i and j type
looping. Thanks again.

D. Parker


Nigel

Looping on Cells with $x$y
 
You can form a cell address by using....

Range("B" & i)

or.......

Range("B" & i & ":B" & j )

but I think you must agree it is messy and difficult to read, also iterating
the columns is also messy. You can use.....

Cells(r1, c1)

for single cells or .....

Range(Cells(r1, c1), Cells(r2, c2))

for a range. These allow you to loop through using the variables
r1,c1,r2,c2 as required. Row first, Column second

--
Cheers
Nigel



"D.Parker" wrote in message
...
Hello. I would like to utilize your expertise again. Is there a way to

to
loop through cells that have the form "$B$2", such as "$Bi$j", where i and

j
are integers. Is this possible? Is so how, because I tried with i and j

type
looping. Thanks again.

D. Parker




Bob Phillips[_6_]

Looping on Cells with $x$y
 
In itself a cell is not absolute ($B$1) or relative (B1), or any combination
thereof. It can contain a formula or a function that uses one of those modes
of addressing, but it could even contain more than one mode, or even all 4.

What specifically are you trying to do?

--

HTH

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


"D.Parker" wrote in message
...
Hello. I would like to utilize your expertise again. Is there a way to

to
loop through cells that have the form "$B$2", such as "$Bi$j", where i and

j
are integers. Is this possible? Is so how, because I tried with i and j

type
looping. Thanks again.

D. Parker





All times are GMT +1. The time now is 07:58 PM.

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