write at exceltoexplore@gmail.com : Report Automation|Dashboard in Excel| Provide Excel consulting through macro (VBA) automation |Financial Modeling | Ethical Hacking

Saturday, 24 March 2012

Excel : Fill up Blank Rows in a column


If you your columns have blank rows & data. And you want to fill up blank rows with cells having data.
e.g cell A2 contain 1 and cell A10 contain 2. Rows are blank from A3:A9. try below code which will fill up value if cell A2 till cell A9




Sub Mtest()
Dim i As Long
Dim Temp As String

For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
If Trim((Cells(i, 1)) = "") Then
Cells(i, 1) = Temp
Else
Temp = Cells(i, 1)
End If
Next
End Sub