Forum Discussion
Use VBA to Autofill a Row until the end of the number of data in another row
- Mar 25, 2019
Hi Haytham Amairah,
I was facing similar issues and chanced upon this thread. If i have two columns (O and P) that i wish to autofill via VBA, do I amend the code from:
Selection.AutoFill Destination:=Range("O2:P313")
Range("O2:P313").Selectto:
Selection.AutoFill Destination:=Range("O2:O" & Range("E" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select
Selection.AutoFill Destination:=Range("P2:" & Range("E" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).Select
Hi,
If I understand you well, nothing has to change in the code!
You need to use the below formula in cell H2 to link this cell to cell A2.
=A2
After then, run the code so that you fill this formula down until the last row in column E and make the column H and A linked together.
Regards
Thanks for your help Haytham,
unfortunately I am probably doing something wrong as when I link the Cells then run macro rather than
filling down with the text that is in A2 - cells in H fill down with a zero
- Haytham AmairahAug 24, 2019Silver Contributor
- aimeelouAug 25, 2019Copper Contributor
- Haytham AmairahAug 25, 2019Silver Contributor
If you need to fill the column H with the content of only cell A2 so that each cell in column H will be filled with the same text in cell A2.
Then you just need to lock the formula in cell H2 as follows:
=$A$2