Macro to populate formula using Autofill

Closed
Report
Posts
4
Registration date
Thursday July 4, 2013
Status
Member
Last seen
July 16, 2013
-
Posts
2847
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
January 13, 2022
-
i have 2 worksheets, A & B.
In worksheet A, i have the data in cell F2, F3, F4.

In worksheet B, i would like to refer worksheetA!F2 in Column G, worksheetA!F3 in Column H and worksheetA!F4 in Column J. The data in worksheet B would be autofilled all the way down from row 2 to as long as Column B has data.

Could someone pls help? I'm a newbie to macros.

Thanks.

3 replies

Posts
2847
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
January 13, 2022
491
Hi Mayek,

Here is your requested code:
Sub AutofillGHJ()
Dim lRow As Integer

Sheets("B").Select

lRow = Range("B" & Rows.Count).End(xlUp).Row
Range("G1:H1").Autofill Range("G1:H" & lRow)
Range("J1").Autofill Range("J1:J" & lRow)
    
End Sub

Best regards,
Trowa
0
Posts
4
Registration date
Thursday July 4, 2013
Status
Member
Last seen
July 16, 2013

Hi Trowa,

I actually managed to figure out the macros by using recording and modifying it from there. Although it is slightly long, but its workable. The macros you had provided are very simple and workable.

Thank you.

Regards
0
Posts
2847
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
January 13, 2022
491
Hi Mayek,

Hopefully it will help you in creating smaller macro's. As this will be beneficial to the file size.

Best regards,
Trowa
0