Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim c() As Integer
Dim ends(20) As Integer For d = Sheet11.Cells(18, 14).Value - 1 To 0 Step -1 ends(d) = Range("A50000").End(xlUp).Row c() = ends() Next d 'end stud loop ReDim Preserve c(Sheet11.Cells(18, 14).Value - 1) The data in the table is backwards. I assume due to the step -1? Is there a VBA command to reverse the data in c() ? Ex. from 1,2,3...to 3,2,1... Suggestions? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Something like this
For i = LBound(ary) To UBound(ary) / 2 tmp = ary(UBound(ary) - i) ary(UBound(ary) - i) = ary(i) ary(i) = tmp Next i -- HTH RP (remove nothere from the email address if mailing direct) "Kevin O'Neill" wrote in message oups.com... Dim c() As Integer Dim ends(20) As Integer For d = Sheet11.Cells(18, 14).Value - 1 To 0 Step -1 ends(d) = Range("A50000").End(xlUp).Row c() = ends() Next d 'end stud loop ReDim Preserve c(Sheet11.Cells(18, 14).Value - 1) The data in the table is backwards. I assume due to the step -1? Is there a VBA command to reverse the data in c() ? Ex. from 1,2,3...to 3,2,1... Suggestions? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Why not just change your for statement:
For d = Sheet11.Cells(18, 14).Value - 1 To 0 Step -1 becomes For d = 0 to Sheet11.Cells(18, 14).Value - 1 But all that did for me was put in the row number of the last used cell in column A in all the elements of the array. I bet that's not what you really wanted. (Ps. The original code did the same thing.) ======== If you wanted to get the last x number of values from column A, you could use something like: Option Explicit Sub testme04() Dim ends As Variant Dim HowMany As Long Dim LastCell As Range dim iCtr as long With sheet11 Set LastCell = .Cells(.Rows.Count, "A").End(xlUp) HowMany = .Cells(18, 14).Value ends = application.transpose(LastCell.Offset(1 - HowMany, 0) _ .Resize(HowMany, 1).Value) End With 'to prove it works for ictr = lbound(ends) to ubound(ends) msgbox ictr & "--" & ends(ictr) next ictr End Sub Kevin O'Neill wrote: Dim c() As Integer Dim ends(20) As Integer For d = Sheet11.Cells(18, 14).Value - 1 To 0 Step -1 ends(d) = Range("A50000").End(xlUp).Row c() = ends() Next d 'end stud loop ReDim Preserve c(Sheet11.Cells(18, 14).Value - 1) The data in the table is backwards. I assume due to the step -1? Is there a VBA command to reverse the data in c() ? Ex. from 1,2,3...to 3,2,1... Suggestions? -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, ended up using this.
ends(ab) = Range("A50000").End(xlUp).Row ab = ab + 1 c() = ends() ReDim Preserve c(Sheet11.Cells(18, 14).Value - 1) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Reverse a function to return the array? | Excel Worksheet Functions | |||
search an array in reverse (bottom to top) order | Excel Discussion (Misc queries) | |||
reverse data | Excel Discussion (Misc queries) | |||
how to reverse a range/array? | Excel Worksheet Functions | |||
DATA VALIDATION IN REVERSE | Excel Discussion (Misc queries) |