Replace Null value in Coloumn

P

Plumdodge

I am relatively new to Excel VBA and work primarily with Access. For a
spreadsheet which require frequent importation into Access I need to replace
all null cells in Coloumn A with the value from the cell directly above it.

I.E.

A B C
1 45
2 Null

I would want to replace the blank cell of A2 with the value of 45 from A1.
This macro would go through a various range because the number of rows vary
in length. It would just need to stop at the last row that has a value
present in Coloumn A.

Any ideas or suggestions?
 
B

Bob Phillips

For i = 2 To Cells(Rows.Count,"A").End(xlUp).Row
If Cells(i,"A").Value = "" Then
Cells(i,"A").Value = Cells(i-1,"A").Value
End If
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
P

Plumdodge

Bob,
Thank you very much for the Help!

Bob Phillips said:
For i = 2 To Cells(Rows.Count,"A").End(xlUp).Row
If Cells(i,"A").Value = "" Then
Cells(i,"A").Value = Cells(i-1,"A").Value
End If
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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