print values in an array

R

RobcPettit

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
 
T

Tom Ogilvy

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
 
R

RobcPettit

Thankyou for your reply. This works great. Thankyou for taking the
time.
Regards Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top