ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   refer cell using c (https://www.excelbanter.com/excel-programming/306329-refer-cell-using-c.html)

anupam

refer cell using c
 
The following code where each cell in the the range is referred

for each c in Range("......")
-------
--------
next c

after exiting from for loop i want it to refer immediate next cell.
how can it be possibl

--
Message posted from http://www.ExcelForum.com


Bob Umlas, Excel MVP

refer cell using c
 
Before loop:
Set Orig = ActiveCell

After loop:
Orig.Offset(1).Select

"anupam " wrote:

The following code where each cell in the the range is referred

for each c in Range("......")
-------
--------
next c

after exiting from for loop i want it to refer immediate next cell.
how can it be possible


---
Message posted from http://www.ExcelForum.com/



Alan Beban[_2_]

refer cell using c
 
anupam < wrote:

The following code where each cell in the the range is referred

for each c in Range("......")
-------
--------
next c

after exiting from for loop i want it to refer immediate next cell.
how can it be possible


---
Message posted from http://www.ExcelForum.com/

Immediate next cell after what cell??? Bob Umlas provided code to refer
to the next cell *down* from the cell that was active immediately prior
to the loop. If you meant the next cell to the *right* of the cell that
was active immediately prior to the loop, then you could use

Orig.Offset(0,1)

If you meant the next cell after the last cell in the range through
which the code loops, you could use


Set rng = Range("......")(Range("......").Count + 1)
or
Set rng = Range("......")(Range("......").Rows.Count, _
Range("......").Columns.Count + 1)

depending on what you meant by "the next cell".

Alan Beban


All times are GMT +1. The time now is 12:05 PM.

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