Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Why can't you use this VBA w. array & cell value instead of copy paste?

Hi,

Can I run a vba code to "replicate" cell values to a larger part of a table
with a array solution? Say you have A1:A10 with a number serie like in the
end of this message and want to fill A14:A23, A27:36 etc with the values of
A1:A10. i'm not so god at arrays, but doesn't this code store all 10 values
into the a variable?

[ No, I DON'T want to use the excel handle and just drag it out or just
copy and paste the cells by selecting the compleate range of 300 x 13 cells
and just do one single paste to achieve this. I'm aware of this solution. I
want to be able to ALSO USE this kind of "array solution" in my further vba
code to have a easy way to "replicate" cells VALUES in one range to another
place in the workbook without using copy-paste in the code. ]

'Nothing happends with this code...

Sub UseArraysToCopyRangeCellsValues()
Dim rRow As Long
Dim counter As Long
Dim a As Variant

Let counter = 0
Let rRow = Selection.Row
Let a = Array(Range(Cells(rRow, 10), Cells(rRow + 9, 10)).Cells.Value)
Do While counter < 100
'Debug.Print a
rRow = rRow + 13
counter = counter + 1
ActiveSheet.Range(Cells(rRow, 10), Cells(rRow + 9, 10)).Cells.Value
= a
Loop
End Sub


A1 11
A2 22
A3 33
A4 44
A5 55
A6 66
A7 77
A8 88
A9 99
A10 10
A11
A12
A13
A14 11
A15 22
A16 33
....
and further down
.... ...


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Why can't you use this VBA w. array & cell value instead of copy p

I don't really understand your question. You are confusing an array obkect
with an array formula.

To me, it seems that you just want to copy values down columns?

cl = 1
For rw = 14 to 100 step 13
With Range(Cells(rw,cl),cells(rw + 9,cl))
.Value = Range(Cells(1,cl),cells(10,cl))
End With
Next


when cl = 1 the code will replicate column A.
your example shows 1,14,27 as the first cell of the 'blocks' so that the
last row will be 9+ first row, and that the first row of any block is 13 rows
after the the first row of the preceding block - hence the step 13 in the
for/next loop

HTH
"Maria J-son" wrote:

Hi,

Can I run a vba code to "replicate" cell values to a larger part of a table
with a array solution? Say you have A1:A10 with a number serie like in the
end of this message and want to fill A14:A23, A27:36 etc with the values of
A1:A10. i'm not so god at arrays, but doesn't this code store all 10 values
into the a variable?

[ No, I DON'T want to use the excel handle and just drag it out or just
copy and paste the cells by selecting the compleate range of 300 x 13 cells
and just do one single paste to achieve this. I'm aware of this solution. I
want to be able to ALSO USE this kind of "array solution" in my further vba
code to have a easy way to "replicate" cells VALUES in one range to another
place in the workbook without using copy-paste in the code. ]

'Nothing happends with this code...

Sub UseArraysToCopyRangeCellsValues()
Dim rRow As Long
Dim counter As Long
Dim a As Variant

Let counter = 0
Let rRow = Selection.Row
Let a = Array(Range(Cells(rRow, 10), Cells(rRow + 9, 10)).Cells.Value)
Do While counter < 100
'Debug.Print a
rRow = rRow + 13
counter = counter + 1
ActiveSheet.Range(Cells(rRow, 10), Cells(rRow + 9, 10)).Cells.Value
= a
Loop
End Sub


A1 11
A2 22
A3 33
A4 44
A5 55
A6 66
A7 77
A8 88
A9 99
A10 10
A11
A12
A13
A14 11
A15 22
A16 33
....
and further down
.... ...



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
Copy/Paste array formulae from the newsgroup MartinW Excel Discussion (Misc queries) 6 March 21st 08 06:55 AM
Cannot Copy/Paste Array Formula tb Excel Worksheet Functions 3 December 13th 07 02:26 AM
Select cell, Copy it, Paste it, Return to Previous cell spydor Excel Discussion (Misc queries) 1 December 30th 05 01:29 PM
Need help to Copy and Paste array using macro wira Excel Programming 4 May 11th 05 08:39 AM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM


All times are GMT +1. The time now is 02:47 PM.

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"