Selection.AutoFill = HELP

spcalan

Well-known Member
Joined
Jun 4, 2008
Messages
1,247
I have a column that needs to filling in.

Row 1 may have a number
Rows 2-100 are empty but need row 1's data to be in it.
Then row 101 has something
but row 102-105 are empty.

basically I need to fill in the empty rows with data from a previous row.
( Selection.AutoFill )???
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
See how this works for you...

With Range("A2:A" & Cells(Rows.Count,"A").End(xlup).Row).SpecialCells(xlCellTypeBlanks)
.Formula = "=A1"
.Value = .Value
End With
 
Upvote 0

spcalan

Well-known Member
Joined
Jun 4, 2008
Messages
1,247
See how this works for you...

With Range("A2:A" & Cells(Rows.Count,"A").End(xlup).Row).SpecialCells(xlCellTypeBlanks)
.Formula = "=A1"
.Value = .Value
End With

This just took the first 2 rows with data and pasted them down the range of column A.

Hmm, filled it yes,, but not selection autofill, lol.
 
Upvote 0

spcalan

Well-known Member
Joined
Jun 4, 2008
Messages
1,247
I am thinking that it might be a ----

Cells(1,1) = value

if cells(2,1) is empty then copypaste "value"
if cells ( 3,1) is empty then copypaste "value"
 
Upvote 0

Case_Germany

Active Member
Joined
May 13, 2008
Messages
408
Hi,

perhaps with this code?

Code:
Sub fill_rows_A()
    Dim arrTmp As Variant
    Dim lngRow As Long
    With Worksheets("Sheet1") 'adapt
        arrTmp = .Range(.Cells(1, 1), .Cells(.Rows.Count, 1).End(xlUp))
        For lngRow = 1 To UBound(arrTmp)
            If arrTmp(lngRow, 1) = "" Then arrTmp(lngRow, 1) = arrTmp(lngRow - 1, 1)
        Next
        .Range(.Cells(1, 1), .Cells(UBound(arrTmp), 1)) = arrTmp
    End With
End Sub
Case_Germany
 
Upvote 0

Forum statistics

Threads
1,191,167
Messages
5,985,053
Members
439,936
Latest member
BSR

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top