find last populated cell and autofill column- vba

whitoulias

Board Regular
Joined
Jun 22, 2012
Messages
153
DATADATE
PRICE
DATA20120621 118.1000
DATA20120621149.7700
DATA94.8900
DATA137.5900
DATA114.5500
DATA145.2700
DATA114.5500
DATA92.4000
DATA145.2700

<colgroup><col style="width:48pt" span="3" width="64"> </colgroup><tbody>
</tbody>

i have 3 columns (data, date & price)
What i would like to do is find the last populated cell in 'date' column and autofill it based on column 'data'.
The tricky thing is that the date form is text and while autofilling manually it changes
Any thoughts?

Thanx
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try

Code:
Sub atest()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
With Range("B2:B" & LR)
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    .Value = .Value
End With
End Sub
 
Upvote 0
Or:

Code:
With Range("B" & Rows.Count).End(xlUp)
    Range(.Offset(1, 0), Range("B" & Range("A" & Rows.Count).End(xlUp).Row)) = .Value
End With

Dom
 
Last edited:
Upvote 0
Code:
Sub FillData()
    Dim lastA As Long, lastB As Long
    
    lastA = Cells(Rows.Count, "A").End(xlUp).Row
    lastB = Cells(Rows.Count, "B").End(xlUp).Row
    
    If lastB < lastA Then
        Range("B" & lastB & ":B" & lastA).FillDown
    End If
    
End Sub
 
Upvote 0
Try

Code:
Sub atest()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
With Range("B2:B" & LR)
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    .Value = .Value
End With
End Sub

Perfect
thanx a lot
 
Upvote 0
Code:
Sub FillData()
    Dim lastA As Long, lastB As Long
    
    lastA = Cells(Rows.Count, "A").End(xlUp).Row
    lastB = Cells(Rows.Count, "B").End(xlUp).Row
    
    If lastB < lastA Then
        Range("B" & lastB & ":B" & lastA).FillDown
    End If
    
End Sub

It works fine
though it keeps the format in text
Thank you all
 
Upvote 0

Forum statistics

Threads
1,215,831
Messages
6,127,140
Members
449,362
Latest member
Bracelane

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
Back
Top