Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default 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/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default 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/




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Variable to LINEST RW Excel Worksheet Functions 5 May 24th 05 07:00 PM
passing variable to file... Ernst Guckel[_2_] Excel Programming 1 June 2nd 04 05:46 PM
Passing a variable between workbooks Rich Cooper Excel Programming 1 May 19th 04 07:27 PM
Passing variable from one sub to another Medemper Excel Programming 0 February 26th 04 10:23 PM
Auto Open and Passing variable value(s) to MS Word Sony[_2_] Excel Programming 1 September 29th 03 05:00 AM


All times are GMT +1. The time now is 12:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"