Filling in the blanks methods?

S

Simon

I have a data extract from a crosstab and now on a regular basis need
to fill in the blanks to apply a suitable filter.

Below I've included an example.

A1: 1
A2:
A3:
A4:
A5:
A6:
A7: 2
A8:
A9:
A10:
A11:
A12:
A13:
A14 3

This will continue until 6 is reached and then I will need something
(xlUp?) to obtain the LastRow to stop filling down to 65536.

The ranges are not static and will vary. I've attempted FillDown but
I've come across issues keeping the ranges flexible.

THe data is typically pasted into A6, but that is about all that is
rigid from a point of view of using a suitable ActiveCell range.

A6 is where 1

The gap from where "1", is typically in A6, yet the location for "2"
could be anywhere below , e.g. in A7, A9 , A20 etc.

After A6 the cells below are blank until there is a value of 2 in
whichever cell it is.

However If(IsBlank) works within Excel via the addition of a column
yet I wish to "hardwire" this in VB. Any suggestions?
 
J

Joel

Try this

Sub fill()

LastRow = ActiveSheet.Cells. _
SpecialCells(xlCellTypeLastCell).Row
'find first data
FirstRow = 1
Do While Range("A" & FirstRow) = ""
FirstRow = FirstRow + 1
Loop
Copydata = Range("A" & FirstRow)

For RowCount = (FirstRow + 1) To LastRow
If Range("A" & RowCount) = "" Then
Range("A" & RowCount) = Copydata
Else
Copydata = Range("A" & RowCount)
End If
Next RowCount
End Sub
 
T

Tom Ogilvy

Sub FillData()
With ActiveSheet
Set r = Intersect(.Columns(1), .UsedRange)
End With
Set r1 = r.SpecialCells(xlBlanks)
r1.Formula = "=A1"
r.Copy
r.PasteSpecial xlValues
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