Autofill the column

aliikhlaq2006

New Member
Joined
Apr 4, 2012
Messages
44
I want a VBA that AutoFill the data in A2,B2,C2 to the last value of the Column D
[TABLE="width: 500"]
<tbody>[TR]
[TD]Name[/TD]
[TD]A/C Code[/TD]
[TD]Country[/TD]
[TD]Balance[/TD]
[/TR]
[TR]
[TD]John[/TD]
[TD]001[/TD]
[TD]USA[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]50[/TD]
[/TR]
</tbody>[/TABLE]

In above table the values in A,B,C is automatically autofill to the last value which is 50 in this case of Balance(D)
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try the following code:


Code:
Sub Test()
    On Error Resume Next
    LR = Range("D" & Rows.Count).End(xlUp).Row

    Range("A2:C2").AutoFill Destination:=Range("A2:C" & LR), Type:=xlFillCopy

End Sub
 
Last edited:
Upvote 0
Code:
Sub test()
On Error Resume Next
Range("A3:C" & Range("D" & Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeBlanks).Formula = "=A2"
Range("A:C").Value = Range("A:C").Value
End Sub
 
Upvote 0
Another option
Code:
Sub Chk()
Range("A2:C" & Range("D" & Rows.Count).End(xlUp).Row).FillDown
End Sub
 
Upvote 0
It kind of depends on whether there are other names below the sample given or not.
 
Upvote 0
Try the following code:


Code:
Sub Test()
    On Error Resume Next
    LR = Range("D" & Rows.Count).End(xlUp).Row

    Range("A2:C2").AutoFill Destination:=Range("A2:C" & LR), Type:=xlFillCopy

End Sub
Thank You so much it worked for me one thing more i have a more than 200 sheets can i apply this macro on all sheets by selecting them all
 
Upvote 0
As long as each sheet is set up the same. The following will loop through each sheet and fill the rows.

Code:
Sub Test()

Dim sh As Worksheet

For Each sh In Worksheets
    sh.Activate
    
    On Error Resume Next
    LR = Range("D" & Rows.Count).End(xlUp).Row

    Range("A2:C2").AutoFill Destination:=Range("A2:C" & LR), Type:=xlFillCopy
Next

End Sub
 
Upvote 0
Thank you so much you save my days
As long as each sheet is set up the same. The following will loop through each sheet and fill the rows.

Code:
Sub Test()

Dim sh As Worksheet

For Each sh In Worksheets
    sh.Activate
    
    On Error Resume Next
    LR = Range("D" & Rows.Count).End(xlUp).Row

    Range("A2:C2").AutoFill Destination:=Range("A2:C" & LR), Type:=xlFillCopy
Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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