May 24 2022 07:09 PM
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 until the last row that contain the next value that its different.
The thing looks like this:
And i want to make this in Macro
Thank you very much in advance,
Liber
May 24 2022 07:38 PM
Solution
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
May 24 2022 07:45 PM
May 24 2022 07:46 PM
You're welcome @jorgeliber! Glad I could help.
May 24 2022 07:38 PM
Solution
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