ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   In Excel visual basic - Need an "auto adjusting" fill down macro (https://www.excelbanter.com/excel-programming/406468-excel-visual-basic-need-auto-adjusting-fill-down-macro.html)

cdj-work

In Excel visual basic - Need an "auto adjusting" fill down macro
 
I need to create a macro that will copy (fill) down the contents of cells A2,
B2, C2 based on the populated rows in column D. For instance if rows 2:15 in
column D have values, then I want contents of A2 copied down to A3:A15, B2 to
B3:B15, C2 to C3:C15. If the next time I run the macro rows 2:45 in column D
have values, then the fill down should adjust to A3:A45, B3:B45, C3:C45, etc.

I have very little experience in visual basic, mostly "tweaking" a few
macros that were created via the Excel Macro Recording Function. I can not
figure out how to create an auto adjusting macro to fill down.

Gord Dibben

In Excel visual basic - Need an "auto adjusting" fill down macro
 
Sub Auto_Fill()
Dim Lrow As Long
With ActiveSheet
Lrow = Range("D" & Rows.Count).End(xlUp).Row
Range("A2:C" & Lrow).FillDown
End With
End Sub


Gord Dibben MS Excel MVP

On Thu, 21 Feb 2008 11:41:05 -0800, cdj-work
wrote:

I need to create a macro that will copy (fill) down the contents of cells A2,
B2, C2 based on the populated rows in column D. For instance if rows 2:15 in
column D have values, then I want contents of A2 copied down to A3:A15, B2 to
B3:B15, C2 to C3:C15. If the next time I run the macro rows 2:45 in column D
have values, then the fill down should adjust to A3:A45, B3:B45, C3:C45, etc.

I have very little experience in visual basic, mostly "tweaking" a few
macros that were created via the Excel Macro Recording Function. I can not
figure out how to create an auto adjusting macro to fill down.




All times are GMT +1. The time now is 06:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com