![]() |
Passing Row variable to row Auto fill logic
I want to fill a range. I have a formula in J2 and I want to fill i
down to J10 (8 rows). When I record it, it looks like the code below. However I want the number of rows to fill to be variable. How do pass a row variable to this? Sub Macro8() Sheets("Paste Range").Select Range("J2").Select Selection.AutoFill Destination:=Range("J2:J10") Type:=xlFillDefault Range("J2:J10").Select End Sub Thank -- Message posted from http://www.ExcelForum.com |
Passing Row variable to row Auto fill logic
LastRow controls how many rows to copy the contents of J2 to ........
Sub Macro8() Dim LastRow As Long LastRow = 10 Range("J2").AutoFill Destination:= _ Range(Cells(2, 10), Cells(LastRow, 10)), _ Type:=xlFillDefault End Sub Cheers Nigel "ExcelMonkey " wrote in message ... I want to fill a range. I have a formula in J2 and I want to fill it down to J10 (8 rows). When I record it, it looks like the code below. However I want the number of rows to fill to be variable. How do I pass a row variable to this? Sub Macro8() Sheets("Paste Range").Select Range("J2").Select Selection.AutoFill Destination:=Range("J2:J10"), Type:=xlFillDefault Range("J2:J10").Select End Sub Thanks --- Message posted from http://www.ExcelForum.com/ |
Passing Row variable to row Auto fill logic
Hi
something like Sub Macro8() dim lastrow lastrow=30 Sheets("Paste Range").Range("J2").AutoFill _ Destination:=Range("J2:J" & lastrow), Type:=xlFillDefault End Sub -- Regards Frank Kabel Frankfurt, Germany I want to fill a range. I have a formula in J2 and I want to fill it down to J10 (8 rows). When I record it, it looks like the code below. However I want the number of rows to fill to be variable. How do I pass a row variable to this? Sub Macro8() Sheets("Paste Range").Select Range("J2").Select Selection.AutoFill Destination:=Range("J2:J10"), Type:=xlFillDefault Range("J2:J10").Select End Sub Thanks --- Message posted from http://www.ExcelForum.com/ |
Passing Row variable to row Auto fill logic
"ExcelMonkey " ha scritto nel
messaggio ... I want to fill a range. I have a formula in J2 and I want to fill it down to J10 (8 rows). When I record it, it looks like the code below. However I want the number of rows to fill to be variable. How do I pass a row variable to this? Sub Macro8() Sheets("Paste Range").Select Range("J2").Select Selection.AutoFill Destination:=Range("J2:J10"), Type:=xlFillDefault Range("J2:J10").Select End Sub Sub Macro8() Sheets("Paste Range").Select rstart = 2 rend = 10 Cells(rstart, "J").Select Selection.AutoFill Destination:=Range(Cells(rstart, "J"), Cells(rend, "J")), Type:=xlFillDefault Range(Cells(rstart, "J"), Cells(rend, "J")).Select End Sub |
Passing Row variable to row Auto fill logic
Sub Auto_Fill()
Dim lrow As Long With ActiveSheet lrow = Range("J" & Rows.Count).End(xlUp).Row Range("J2:J" & lrow).FillDown End With End Sub Gord Dibben Excel MVP On Fri, 11 Jun 2004 15:36:01 -0500, ExcelMonkey wrote: I want to fill a range. I have a formula in J2 and I want to fill it down to J10 (8 rows). When I record it, it looks like the code below. However I want the number of rows to fill to be variable. How do I pass a row variable to this? Sub Macro8() Sheets("Paste Range").Select Range("J2").Select Selection.AutoFill Destination:=Range("J2:J10"), Type:=xlFillDefault Range("J2:J10").Select End Sub Thanks --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 12:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com