ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   autofill more then one cell when the cells are not close to each other (https://www.excelbanter.com/excel-programming/385410-autofill-more-then-one-cell-when-cells-not-close-each-other.html)

thread

autofill more then one cell when the cells are not close to each other
 
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?


BigPig

autofill more then one cell when the cells are not close to each o
 
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?



Tom Ogilvy

autofill more then one cell when the cells are not close to each o
 
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,D1:D20,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?




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com