PC Review


Reply
Thread Tools Rate Thread

AutoFill down a varying Range

 
 
=?Utf-8?B?RGVhbkBFUllD?=
Guest
Posts: n/a
 
      13th Oct 2006
Using Excel 2000
I am trying to use autofill to copy a formula down but the range will vary.
M1 is the column header (Title)
M2 has the following formula in: =IF(L2="","ERROR","")
Column A always has a number in it for each row
The number of rows will vary
I have tried the following but it doesn't work - it fills M1 above it but
not the rows below it!
Dim howmany As Long
howmany = Application.CountA("a:a")
Set SourceRange = Range("M2:M2")
'Set fillRange = Range("M2:M19")
Set fillRange = Range("M2:M" & howmany)
SourceRange.AutoFill Destination:=fillRange
Range("M2").Select
Can someone let me know what I'm doing wrong.

Cheers, Dean.
 
Reply With Quote
 
 
 
 
Ken Johnson
Guest
Posts: n/a
 
      13th Oct 2006

Dean@ERYC wrote:
> Using Excel 2000
> I am trying to use autofill to copy a formula down but the range will vary.
> M1 is the column header (Title)
> M2 has the following formula in: =IF(L2="","ERROR","")
> Column A always has a number in it for each row
> The number of rows will vary
> I have tried the following but it doesn't work - it fills M1 above it but
> not the rows below it!
> Dim howmany As Long
> howmany = Application.CountA("a:a")
> Set SourceRange = Range("M2:M2")
> 'Set fillRange = Range("M2:M19")
> Set fillRange = Range("M2:M" & howmany)
> SourceRange.AutoFill Destination:=fillRange
> Range("M2").Select
> Can someone let me know what I'm doing wrong.
>
> Cheers, Dean.


Hi Dean,

try...

Dim howmany As Long
howmany = WorksheetFunction.CountA(Range("a:a"))
Set SourceRange = Range("M2")
Set fillRange = Range("M2:M" & howmany)
SourceRange.AutoFill Destination:=fillRange
Range("M2").Select

Ken Johnson

 
Reply With Quote
 
=?Utf-8?B?RGVhbkBFUllD?=
Guest
Posts: n/a
 
      13th Oct 2006
Thanks Ken thats sorted it.

Thank-you very much.

Dean

"Ken Johnson" wrote:

>
> Dean@ERYC wrote:
> > Using Excel 2000
> > I am trying to use autofill to copy a formula down but the range will vary.
> > M1 is the column header (Title)
> > M2 has the following formula in: =IF(L2="","ERROR","")
> > Column A always has a number in it for each row
> > The number of rows will vary
> > I have tried the following but it doesn't work - it fills M1 above it but
> > not the rows below it!
> > Dim howmany As Long
> > howmany = Application.CountA("a:a")
> > Set SourceRange = Range("M2:M2")
> > 'Set fillRange = Range("M2:M19")
> > Set fillRange = Range("M2:M" & howmany)
> > SourceRange.AutoFill Destination:=fillRange
> > Range("M2").Select
> > Can someone let me know what I'm doing wrong.
> >
> > Cheers, Dean.

>
> Hi Dean,
>
> try...
>
> Dim howmany As Long
> howmany = WorksheetFunction.CountA(Range("a:a"))
> Set SourceRange = Range("M2")
> Set fillRange = Range("M2:M" & howmany)
> SourceRange.AutoFill Destination:=fillRange
> Range("M2").Select
>
> Ken Johnson
>
>

 
Reply With Quote
 
=?Utf-8?B?RGVhbkBFUllD?=
Guest
Posts: n/a
 
      13th Oct 2006
Thanks Ken thats sorted it.

Thank-you very much.

Cheers, Dean

"Ken Johnson" wrote:

>
> Dean@ERYC wrote:
> > Using Excel 2000
> > I am trying to use autofill to copy a formula down but the range will vary.
> > M1 is the column header (Title)
> > M2 has the following formula in: =IF(L2="","ERROR","")
> > Column A always has a number in it for each row
> > The number of rows will vary
> > I have tried the following but it doesn't work - it fills M1 above it but
> > not the rows below it!
> > Dim howmany As Long
> > howmany = Application.CountA("a:a")
> > Set SourceRange = Range("M2:M2")
> > 'Set fillRange = Range("M2:M19")
> > Set fillRange = Range("M2:M" & howmany)
> > SourceRange.AutoFill Destination:=fillRange
> > Range("M2").Select
> > Can someone let me know what I'm doing wrong.
> >
> > Cheers, Dean.

>
> Hi Dean,
>
> try...
>
> Dim howmany As Long
> howmany = WorksheetFunction.CountA(Range("a:a"))
> Set SourceRange = Range("M2")
> Set fillRange = Range("M2:M" & howmany)
> SourceRange.AutoFill Destination:=fillRange
> Range("M2").Select
>
> Ken Johnson
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort data with a varying range Scott Microsoft Excel Programming 3 19th Jan 2010 07:28 PM
CountA formila for a varying range Simon Microsoft Excel Programming 1 11th Jul 2008 11:26 AM
concatenate with a varying range of cells =?Utf-8?B?Uml2ZXJzYWdl?= Microsoft Excel Worksheet Functions 0 29th Jan 2007 07:43 PM
Range varying in for loop McManCSU Microsoft Excel Programming 1 16th Jun 2005 06:24 PM
sumif range of varying size =?Utf-8?B?S00wMQ==?= Microsoft Excel Worksheet Functions 2 30th Mar 2005 10:19 AM


Features
 

Advertising
 

Newsgroups
 


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