I have various empty cells in a table that I want to fill with the last known value in that column.
Sub autofiller()
Dim DataRange As Range
Set DataRange = Range("A1:D4")
Dim i As Integer
FillA = ""
For Each cell In DataRange
If cell(1, 1).Value <> "" Then
FillA = cell(1, 1).Value
Else
cell(1, 1).Value = FillA
End If
i = i + 1
Range("C1").Value = i
Next
End Sub
There will be no empty values in the first row. My logic is that it will look through every cell in that range, and if it is not an empty cell, pick up the value until it hits an empty cell where then I will place that value. The i counter is for me to keep track. It seems to me that the code is checking cell by cell horizontally but I want it to check cell by cell vertically. How can I make it check vertically?
I am new to VBA so any additional comments/guides will help.