Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 90244

Reverse an array in Excel VBA

$
0
0

I have the following code, which based on the logic it should work.

I want it to be (4,3,2,1), but at the end of the loop I get t=(4,3,3,4)

Sub try()

  Dim t As Variant

  t = Array(1, 2, 3, 4)
  a = UBound(t)

  For k = 0 To a
    t(k) = t(a - k)
  Next k

End Sub

Any ideas?


Viewing all articles
Browse latest Browse all 90244


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>