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 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
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_sktneerSilver 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
- jorgeliberCopper ContributorThanks for your response. You earn my respect and save my **bleep**.
- Subodh_Tiwari_sktneerSilver Contributor
You're welcome jorgeliber! Glad I could help.