ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loops (https://www.excelbanter.com/excel-programming/285023-loops.html)

PaulSinki

Loops
 
Hi, I was hoping that someone might be able to help me.
I have a list of data that can change in length in terms of rows, but I
want to have a macro that will paste a formula into the adjacent cell
for every non-blank cell within the data set.
ie Column B has 84 rows this time, I want to put a formula in Column C
for the matching number of rows, but when I run the macro next time, I
want it to be able to do the same thing if there is 90 or 40 rows in
Column B.
Any help greatly appreciated!
Thanks,
Paul


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


igor

Loops
 
you can try something like
For row =1to 65000
your code goes here

If cells(row,2)="" then exit sub
next row

good luck

-----Original Message-----
Hi, I was hoping that someone might be able to help me.
I have a list of data that can change in length in terms

of rows, but I
want to have a macro that will paste a formula into the

adjacent cell
for every non-blank cell within the data set.
ie Column B has 84 rows this time, I want to put a

formula in Column C
for the matching number of rows, but when I run the macro

next time, I
want it to be able to do the same thing if there is 90 or

40 rows in
Column B.
Any help greatly appreciated!
Thanks,
Paul


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

.


Caroline[_2_]

Loops
 
Define column B as a Range
ColumnB.Select
Dim Cell As Range
For Each Cell In Selection
If cell. value ="" then Cell.offset(0,1).value =
etc...
Next Cell

Should work

-----Original Message-----
Hi, I was hoping that someone might be able to help me.
I have a list of data that can change in length in terms

of rows, but I
want to have a macro that will paste a formula into the

adjacent cell
for every non-blank cell within the data set.
ie Column B has 84 rows this time, I want to put a

formula in Column C
for the matching number of rows, but when I run the

macro next time, I
want it to be able to do the same thing if there is 90

or 40 rows in
Column B.
Any help greatly appreciated!
Thanks,
Paul


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

.


Tom Ogilvy

Loops
 
Dim rng as Range
set rng = Range(Cells(1,2),Cells(1,2).End(xldown))
rng.offset(0,1).Paste

--
Regards,
Tom Ogilvy

"PaulSinki" wrote in message
...
Hi, I was hoping that someone might be able to help me.
I have a list of data that can change in length in terms of rows, but I
want to have a macro that will paste a formula into the adjacent cell
for every non-blank cell within the data set.
ie Column B has 84 rows this time, I want to put a formula in Column C
for the matching number of rows, but when I run the macro next time, I
want it to be able to do the same thing if there is 90 or 40 rows in
Column B.
Any help greatly appreciated!
Thanks,
Paul


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





All times are GMT +1. The time now is 03:40 PM.

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