ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I advance the range by one row Excell VBA automatically (https://www.excelbanter.com/excel-discussion-misc-queries/10434-how-do-i-advance-range-one-row-excell-vba-automatically.html)

Eric

How do I advance the range by one row Excell VBA automatically
 
I am using

Sheets(Array("Breakfast", "Lunch", "Supper", "Bedtime")).Select
Range("B94:D98").Select

but when I run this more than once it overwrites what was put in the first
time.


dim rng1 as range
dim rng2 as range
set rng1 = range("B94:D98")
do while something 'or do until something
set rng2 = rng1.offset(1,0)'rng2 is 1 row down from rng1
Sheets(Array
("Breakfast", "Lunch", "Supper", "Bedtime")).Select
'more code??
set rng1 = rng2 'move down 1 row. resets at loop start.
loop
this do loop will move you down the sheet 1 row at a time
each loop.
you will have to have find a way out of the loop or it
will go down to row 65536 and crash on you.
-----Original Message-----
I am using

Sheets(Array

("Breakfast", "Lunch", "Supper", "Bedtime")).Select
Range("B94:D98").Select

but when I run this more than once it overwrites what was

put in the first
time.
.



All times are GMT +1. The time now is 11:33 AM.

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