![]() |
Autofill dynamic no. of rows and columns
Hi,
I'm trying to copy the formulas from the first row starting from B2 to some finite column number and applying these formulas (which may be different) to a dynamic number of rows. In other words, the "BK6" is not a fixed value. How can I achieve this? Thanks! Range("B2").Select Range(Selection, Selection.End(xlToRight)).Select Selection.AutoFill Destination:=Range("B2:BK6"), _Type:=xlFillDefault |
Autofill dynamic no. of rows and columns
Do you want this final row to be user specified?
Dim iLastCol As Long Dim iLastRow As Long iLastCol = Cells(2, Columns.Count).End(xlToLeft).Column iLastRow = InputBox("specify last row #") Range("B2", Cells(2, iLastCol)).AutoFill _ Destination:=Range("B2", Cells(iLastRow, iLastCol)), Type:=xlFillDefault -- HTH Bob Phillips wrote in message ps.com... Hi, I'm trying to copy the formulas from the first row starting from B2 to some finite column number and applying these formulas (which may be different) to a dynamic number of rows. In other words, the "BK6" is not a fixed value. How can I achieve this? Thanks! Range("B2").Select Range(Selection, Selection.End(xlToRight)).Select Selection.AutoFill Destination:=Range("B2:BK6"), _Type:=xlFillDefault |
Autofill dynamic no. of rows and columns
Nope. It should be determined through a count of the first column's
number of rows. Will try out your suggestion. Thanks! |
Autofill dynamic no. of rows and columns
Okay, then use this
Dim iLastCol As Long Dim iLastRow As Long iLastCol = Cells(2, Columns.Count).End(xlToLeft).Column iLastRow = Cells(Rows.Count,"B").End(xlUp).Row Range("B2", Cells(2, iLastCol)).AutoFill _ Destination:=Range("B2", Cells(iLastRow, iLastCol)), _ Type:=xlFillDefault -- HTH Bob Phillips wrote in message oups.com... Nope. It should be determined through a count of the first column's number of rows. Will try out your suggestion. Thanks! |
Autofill dynamic no. of rows and columns
Thanks Bob, works like a charm.
Yeh Wei |
All times are GMT +1. The time now is 12:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com