Macro to populate formula using Autofill

Closed
mayek25 Posts 4 Registration date Thursday July 4, 2013 Status Member Last seen July 16, 2013 - Jul 4, 2013 at 09:45 PM
TrowaD Posts 2913 Registration date Sunday September 12, 2010 Status Moderator Last seen November 21, 2022 - Jul 15, 2013 at 11:26 AM
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

TrowaD Posts 2913 Registration date Sunday September 12, 2010 Status Moderator Last seen November 21, 2022 541
Jul 9, 2013 at 11:50 AM
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
mayek25 Posts 4 Registration date Thursday July 4, 2013 Status Member Last seen July 16, 2013
Jul 9, 2013 at 09:01 PM
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
TrowaD Posts 2913 Registration date Sunday September 12, 2010 Status Moderator Last seen November 21, 2022 541
Jul 15, 2013 at 11:26 AM
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