ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   print values in an array (https://www.excelbanter.com/excel-programming/382109-print-values-array.html)

RobcPettit[_2_]

print values in an array
 
Hi, I have an array 'Static runner()' which I redim when code calls
for it. 'redim runner(1 to 1, 1 to idex)'. Idex is a counter. The
arrays perfect, does everthing I want it to, but I cant seem to figure
out this. (Im sure Ive asked before but cant find the reply). If my
array has 100 values, how do I send just the last 30 values to the
worksheet. Im using Range("o1").Resize(UBound(Runner, 2), 1) =
Application.Transpose(Runner), but this adds all values.
Regards Robert


Tom Ogilvy

print values in an array
 
Here is one way:

Sub aBC()
Static runner()
Dim idex As Long
Dim v As Variant
Dim i As Long, j As Long
idex = 100
ReDim runner(1 To 1, 1 To idex)
For i = 1 To idex
runner(1, i) = Chr(Int(Rnd() * 26 + 65))
Next
j = 1
ReDim v(1 To 30, 1 To 1)
For i = idex - 30 + 1 To idex
v(j, 1) = runner(1, i)
j = j + 1
Next
Range("o1").Resize(UBound(v, 1), 1) = v

End Sub

--
Regards,
Tom Ogilvy


"RobcPettit" wrote in message
ups.com...
Hi, I have an array 'Static runner()' which I redim when code calls
for it. 'redim runner(1 to 1, 1 to idex)'. Idex is a counter. The
arrays perfect, does everthing I want it to, but I cant seem to figure
out this. (Im sure Ive asked before but cant find the reply). If my
array has 100 values, how do I send just the last 30 values to the
worksheet. Im using Range("o1").Resize(UBound(Runner, 2), 1) =
Application.Transpose(Runner), but this adds all values.
Regards Robert




RobcPettit[_2_]

print values in an array
 
Thankyou for your reply. This works great. Thankyou for taking the
time.
Regards Robert

On 29 Jan, 00:11, "Tom Ogilvy" wrote:
Here is one way:

Sub aBC()
Static runner()
Dim idex As Long
Dim v As Variant
Dim i As Long, j As Long
idex = 100
ReDim runner(1 To 1, 1 To idex)
For i = 1 To idex
runner(1, i) = Chr(Int(Rnd() * 26 + 65))
Next
j = 1
ReDim v(1 To 30, 1 To 1)
For i = idex - 30 + 1 To idex
v(j, 1) = runner(1, i)
j = j + 1
Next
Range("o1").Resize(UBound(v, 1), 1) = v

End Sub

--
Regards,
Tom Ogilvy

"RobcPettit" wrote in oglegroups.com...

Hi, I have an array 'Static runner()' which I redim when code calls
for it. 'redim runner(1 to 1, 1 to idex)'. Idex is a counter. The
arrays perfect, does everthing I want it to, but I cant seem to figure
out this. (Im sure Ive asked before but cant find the reply). If my
array has 100 values, how do I send just the last 30 values to the
worksheet. Im using Range("o1").Resize(UBound(Runner, 2), 1) =
Application.Transpose(Runner), but this adds all values.
Regards Robert




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

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