Forum Discussion
jorgeliber
May 25, 2022Copper Contributor
Use VBA to Autofill a Row until the end of the number of data in another row
I need some help with the following problem: I need to built a Macro that could make the following thing: The Macro should select the first cell with a value and autofill with the same value ...
- May 25, 2022
Please try this...
Sub Autofil() Dim Rng As Range Dim lr As Long Application.ScreenUpdating = False lr = Range("A" & Rows.Count).End(xlUp).Row On Error Resume Next Set Rng = Range("X2:X" & lr).SpecialCells(xlCellTypeBlanks) On Error GoTo 0 If Not Rng Is Nothing Then Rng.Formula2R1C1 = "=R[-1]C" Range("X2:X" & lr).Value = Range("X2:X" & lr).Value End If Application.ScreenUpdating = True End Sub
Subodh_Tiwari_sktneer
May 25, 2022Silver Contributor
Please try this...
Sub Autofil()
Dim Rng As Range
Dim lr As Long
Application.ScreenUpdating = False
lr = Range("A" & Rows.Count).End(xlUp).Row
On Error Resume Next
Set Rng = Range("X2:X" & lr).SpecialCells(xlCellTypeBlanks)
On Error GoTo 0
If Not Rng Is Nothing Then
Rng.Formula2R1C1 = "=R[-1]C"
Range("X2:X" & lr).Value = Range("X2:X" & lr).Value
End If
Application.ScreenUpdating = True
End Sub
- jorgeliberMay 25, 2022Copper ContributorThanks for your response. You earn my respect and save my **bleep**.
- Subodh_Tiwari_sktneerMay 25, 2022Silver Contributor
You're welcome jorgeliber! Glad I could help.