PC Review


Reply
Thread Tools Rate Thread

autofill more then one cell when the cells are not close to each other

 
 
thread
Guest
Posts: n/a
 
      16th Mar 2007
is it possible to autofill data in more then one field in one command
code when the cells are not close to each other?

for example
range("A1,D1,G1).select
i would like to autofill of them at one command is it posible?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmlnUGln?=
Guest
Posts: n/a
 
      16th Mar 2007
thread,

I am a vba newbie, this small excerpt should get you started and works fine
for me.

Dim Lastrow As Long
Lastrow = Worksheets("urspreadsheet").Cells(Rows.Count, "A").End(xlUp).Row

Set SourceRange = Worksheets("urspreadsheet").Range("b2")
Set fillRange = Worksheets("urspreadsheet").Range("b2:b" & Lastrow)
SourceRange.AutoFill Destination:=fillRange

Add the three lines above as necessary for other columns.


"thread" wrote:

> is it possible to autofill data in more then one field in one command
> code when the cells are not close to each other?
>
> for example
> range("A1,D1,G1).select
> i would like to autofill of them at one command is it posible?
>
>

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      16th Mar 2007
No, I believe you would have to do it separately.

this plays at doing it together, but actually does it separately

Sub Autofill()
Dim SourceRange as Range, FillRange as Range
Dim ar as Range, i as Long
Set SourceRange = Worksheets("Sheet2") _
.Range("A1,D1,G1")
Set fillRange = Worksheets("Sheet2") _
.Range("A1:A20,D120,G1:G20")
i = 1
For Each ar In SourceRange.Areas
ar.Autofill Destination:=fillRange.Areas(i)
i = i + 1
Next
End Sub

--
Regards,
Tom Ogilvy


"thread" wrote:

> is it possible to autofill data in more then one field in one command
> code when the cells are not close to each other?
>
> for example
> range("A1,D1,G1).select
> i would like to autofill of them at one command is it posible?
>
>

 
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
I can't autofill cells in a column if blank cells in between SJ Microsoft Excel Worksheet Functions 1 4th May 2008 01:27 AM
Autofill cell/sets of cells based upon value selected from a list. =?Utf-8?B?QnJhemls?= Microsoft Excel Misc 1 5th Feb 2007 08:45 AM
Autofill: Need to autofill one week block, (5) weekday only into cells. dstock Microsoft Excel Misc 1 17th Jun 2005 08:21 PM
Autofill a range of cells based a a txt value in a separate cell c20driver Microsoft Excel Misc 2 5th May 2004 03:26 PM
Outlook XP - autofill cache emptying on close redbeard Microsoft Outlook 1 4th Nov 2003 08:36 AM


Features
 

Advertising
 

Newsgroups
 


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