PC Review


Reply
Thread Tools Rate Thread

Autofil syntax to auto-complete the range

 
 
John Keith
Guest
Posts: n/a
 
      5th Sep 2008
When using the macro recorder to autofil...
Range("F3").Select
Selection.AutoFill Destination:=Range("F3:F75")

F75 was chosen as the end point because the data in Column E stopped at row
75.

Is there a way to code the autofil so that the end point is dynamic with out
having to calculate the ending row?

Something like...
Range("E3").AutoFill Destination:=Range(Range("E3"),
Range("E3").End(xlDown)) <- xlDown takes the autofil to row 65536. How do I
make it stop at 75?

--
Regards,
John
 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      5th Sep 2008
Hi John

Try this:

LastRow = Range("E3").End(xlDown).Row
Range("F3").AutoFill Destination:=Range("F3", Cells(LastRow, "F"))

Regards,
Per

"John Keith" <(E-Mail Removed)> skrev i meddelelsen
news:22E49DC1-185F-49B0-9AD5-(E-Mail Removed)...
> When using the macro recorder to autofil...
> Range("F3").Select
> Selection.AutoFill Destination:=Range("F3:F75")
>
> F75 was chosen as the end point because the data in Column E stopped at
> row
> 75.
>
> Is there a way to code the autofil so that the end point is dynamic with
> out
> having to calculate the ending row?
>
> Something like...
> Range("E3").AutoFill Destination:=Range(Range("E3"),
> Range("E3").End(xlDown)) <- xlDown takes the autofil to row 65536. How do
> I
> make it stop at 75?
>
> --
> Regards,
> John


 
Reply With Quote
 
John Keith
Guest
Posts: n/a
 
      5th Sep 2008
Thanks, that solved the problem.

I modified it slightly, once I saw the quick way to calculate the last row
used.

lRow = Range("D3").End(xlDown).Row
Range("E3").AutoFill Destination:=Range("E3:E" & lRow)

And at first forgot I was referenced the column "in front" of the
destination to get the last row. I.E. the last row of D... to use as the
last row in the destinatio Column E.

And I never have liked the Cell( ) style of range references.

--
Regards,
John


"Per Jessen" wrote:

> Hi John
>
> Try this:
>
> LastRow = Range("E3").End(xlDown).Row
> Range("F3").AutoFill Destination:=Range("F3", Cells(LastRow, "F"))
>
> Regards,
> Per
>
> "John Keith" <(E-Mail Removed)> skrev i meddelelsen
> news:22E49DC1-185F-49B0-9AD5-(E-Mail Removed)...
> > When using the macro recorder to autofil...
> > Range("F3").Select
> > Selection.AutoFill Destination:=Range("F3:F75")
> >
> > F75 was chosen as the end point because the data in Column E stopped at
> > row
> > 75.
> >
> > Is there a way to code the autofil so that the end point is dynamic with
> > out
> > having to calculate the ending row?
> >
> > Something like...
> > Range("E3").AutoFill Destination:=Range(Range("E3"),
> > Range("E3").End(xlDown)) <- xlDown takes the autofil to row 65536. How do
> > I
> > make it stop at 75?
> >
> > --
> > Regards,
> > John

>
>

 
Reply With Quote
 
Per Jessen
Guest
Posts: n/a
 
      6th Sep 2008
Hi John

Thanks for your reply. I'm glad to help.

Regards,
Per

"John Keith" <(E-Mail Removed)> skrev i meddelelsen
news:7BFF86B0-8EA0-48CC-B1FC-(E-Mail Removed)...
> Thanks, that solved the problem.
>
> I modified it slightly, once I saw the quick way to calculate the last row
> used.
>
> lRow = Range("D3").End(xlDown).Row
> Range("E3").AutoFill Destination:=Range("E3:E" & lRow)
>
> And at first forgot I was referenced the column "in front" of the
> destination to get the last row. I.E. the last row of D... to use as the
> last row in the destinatio Column E.
>
> And I never have liked the Cell( ) style of range references.
>
> --
> Regards,
> John
>
>
> "Per Jessen" wrote:
>
>> Hi John
>>
>> Try this:
>>
>> LastRow = Range("E3").End(xlDown).Row
>> Range("F3").AutoFill Destination:=Range("F3", Cells(LastRow, "F"))
>>
>> Regards,
>> Per
>>
>> "John Keith" <(E-Mail Removed)> skrev i meddelelsen
>> news:22E49DC1-185F-49B0-9AD5-(E-Mail Removed)...
>> > When using the macro recorder to autofil...
>> > Range("F3").Select
>> > Selection.AutoFill Destination:=Range("F3:F75")
>> >
>> > F75 was chosen as the end point because the data in Column E stopped at
>> > row
>> > 75.
>> >
>> > Is there a way to code the autofil so that the end point is dynamic
>> > with
>> > out
>> > having to calculate the ending row?
>> >
>> > Something like...
>> > Range("E3").AutoFill Destination:=Range(Range("E3"),
>> > Range("E3").End(xlDown)) <- xlDown takes the autofil to row 65536. How
>> > do
>> > I
>> > make it stop at 75?
>> >
>> > --
>> > Regards,
>> > John

>>
>>


 
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
RE: Proper syntax for selecting a range using cells instead of range arjen van... Microsoft Excel Programming 0 22nd Jul 2009 06:23 AM
Re: Proper syntax for selecting a range using cells instead of range Per Jessen Microsoft Excel Programming 0 22nd Jul 2009 06:15 AM
how do I get Word to auto complete the complete date? Microsoft Word New Users 8 25th Sep 2007 02:26 PM
Auto-Fill / Auto-Suggest / Auto-Complete =?Utf-8?B?VGlubGV5UGFya0lMR2Fs?= Microsoft Outlook Contacts 2 5th Jan 2005 07:00 PM
Re: Still having syntax problems; graphing a named range that includes indirects to a non-contiguous range of data dvt Microsoft Excel Misc 0 29th Jul 2003 09:49 PM


Features
 

Advertising
 

Newsgroups
 


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