fill dowb using macro

T

tom_mcd

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
 
J

Joel

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
 
T

tom_mcd

brilliant , thanks very much

Joel said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top