tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,834
- Office Version
- 365
- 2019
- Platform
- Windows
It is well known that when writing VBA to use on a Mac, things to avoid include ActiveX objects, Dictionaries and APIs.
Today I came across a problem and thankfully I was told where the problem was.
The following code returns different results depending whether it's run on Windows or Mac.
Feel free to test.
On Windows, it returns the values 1, 2 and 3.
On a Mac, it'll return blank.
Today I came across a problem and thankfully I was told where the problem was.
The following code returns different results depending whether it's run on Windows or Mac.
Feel free to test.
Code:
Option Explicit
Dim Counter As Integer
Public Sub Start()
Sheet1.Cells(1, 1).Resize(Counter, 1).Value = Sec()
End Sub
Public Function Sec() As Variant
Counter = 3
Dim NewArray() As Variant
ReDim NewArray(1 To Counter, 1 To 1) As Variant
Dim i As Integer
For i = 1 To Counter
NewArray(i, 1) = i
Next i
Sec = NewArray()
End Function
On Windows, it returns the values 1, 2 and 3.
On a Mac, it'll return blank.