View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan Drummond[_3_] Rowan Drummond[_3_] is offline
external usenet poster
 
Posts: 414
Default Help: How do I fill a column with values if it is blank?

Wild guess:

Sub BVals()
Dim eRow As Long
Dim ColB As Range
Dim cell As Range
eRow = Cells(Rows.Count, 1).End(xlUp).Row
Set ColB = Range(Cells(2, 2), Cells(eRow, 2))
For Each cell In ColB
If cell.Offset(0, -1).Value < Empty _
And cell.Value = Empty Then cell.Value = 0
Next cell
End Sub

Hopet this helps
Rowan

limshady411 wrote:
Hello,

How do I fill a column of cells with values if it is empty? I want to
fill empty cells with a 0 (zero). The tricky part is, the cells should
only be filled if they are in a row. For instance, A25 has data in it,
but B25 doesn't, but some cells in column b has value, so b25 needs to
have a zero in it since it is in row 25.

I'm not sure how to approach this.

Thanks!