ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   fill dowb using macro (https://www.excelbanter.com/excel-programming/431922-fill-dowb-using-macro.html)

tom_mcd[_2_]

fill dowb using macro
 
I have the following spreadsheet that shows the following coluns A and B.
Cloumn A has a ref number whci needs to be inptu into Column B, however in
Column A where there is a 0 in the column below the ref number above it has
to be input into column B until you come to a different ref number in cloumn
A. for eg below.

A1 B1
1234 1234
0 1234
5678 5678
0 5678
0 5678
7881 7881
8992 8992
0 8992
Does anyone know how to achieve this automatically. I can do it using the If
statement but these can be massive files and are for inexperienced users so
i want to be able for them to run this auromatically by way of Macro if
possible.
Thanks in anticipation once again

joel

fill dowb using macro
 
Real simple. Done this a thousand times before.

Sub FixColumns()

RowCount = 1
Do While Range("A" & RowCount) < ""
If Range("A" & RowCount) < 0 Then
RefNo = Range("A" & RowCount)
End If
Range("B" & RowCount) = RefNo

RowCount = RowCount + 1
Loop

End Sub


"tom_mcd" wrote:

I have the following spreadsheet that shows the following coluns A and B.
Cloumn A has a ref number whci needs to be inptu into Column B, however in
Column A where there is a 0 in the column below the ref number above it has
to be input into column B until you come to a different ref number in cloumn
A. for eg below.

A1 B1
1234 1234
0 1234
5678 5678
0 5678
0 5678
7881 7881
8992 8992
0 8992
Does anyone know how to achieve this automatically. I can do it using the If
statement but these can be massive files and are for inexperienced users so
i want to be able for them to run this auromatically by way of Macro if
possible.
Thanks in anticipation once again


tom_mcd[_2_]

fill dowb using macro
 
brilliant , thanks very much

"Joel" wrote:

Real simple. Done this a thousand times before.

Sub FixColumns()

RowCount = 1
Do While Range("A" & RowCount) < ""
If Range("A" & RowCount) < 0 Then
RefNo = Range("A" & RowCount)
End If
Range("B" & RowCount) = RefNo

RowCount = RowCount + 1
Loop

End Sub


"tom_mcd" wrote:

I have the following spreadsheet that shows the following coluns A and B.
Cloumn A has a ref number whci needs to be inptu into Column B, however in
Column A where there is a 0 in the column below the ref number above it has
to be input into column B until you come to a different ref number in cloumn
A. for eg below.

A1 B1
1234 1234
0 1234
5678 5678
0 5678
0 5678
7881 7881
8992 8992
0 8992
Does anyone know how to achieve this automatically. I can do it using the If
statement but these can be massive files and are for inexperienced users so
i want to be able for them to run this auromatically by way of Macro if
possible.
Thanks in anticipation once again



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

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