Excel 2011 Buggs

Mike

Sorry that I did not answer before but I could not come to the board yesterday.

Using your example this is how I usually like to do it:

Code:
Sub test()
    Dim testArray() As String
 
    ReDim testArray(1 To 3)
    testArray(1) = "a"
    testArray(2) = "b"
    testArray(3) = "c"
 
    MsgBox Join(reverseArray(testArray))
End Sub
 
Function reverseArray(aArray() As String) As String()
    Dim Low As Long, High As Long, i As Long
    Dim Result() As String
 
    Low = LBound(aArray): High = UBound(aArray)
    ReDim Result(Low To High)
 
    For i = Low To High
        Result(i) = aArray(High - i + Low)
    Next i
    reverseArray = Result
End Function

Although this has worked in Windows since excel 2000, it would not work in the Mac, because it still had vba5.

I'm curious to know if this finally works in excel 2011. If you find the time to test it please post the result.

Remark: I changed the type in the arrays to String to use the Join(), that expects an array of substrings, but the function could return any typed array.

I guess I'm not sharing your dislike of variant arrays.

Well, I recognise that I'm a fan(atic) of strong typing. :)

I know vba needs variants sometimes but, being given the choice, I prefer to be specific about the type.
 
Last edited:

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
...I'm curious to know if this finally works in excel 2011. If you find the time to test it please post the result.
...
Yes, the code you posted works in Excel 2011.
It also works if
Code:
Redim reverseArray(1 to 4)
is added at the end.

This is good, in some situations, I prefer using String arrays so a ReDim will fill with a null stiring null rather than a 0 null.
 
Yes, the code you posted works in Excel 2011.

... I prefer using String arrays so a ReDim will fill with a null stiring null rather than a 0 null.

Great!

Good point. That's another advantaged of returning a typed array, the elements of the array are initialised with the corresponding initial value for the type.
 

Forum statistics

Threads
1,222,630
Messages
6,167,191
Members
452,104
Latest member
jadethejade

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top