Ваш код VBA содержит некоторые ошибки. Ваш код VBA возвращает ошибку #VALUE!
на лист, потому что вы пытаетесь назначить содержимое для Object
, как если бы это был массив. Ошибка появляется из этой строки: Output(0,0) = 1
Output
может быть типа Variant
или типа String
Output
и testF
необходимо быть того же типа.
Следующие работы, как ожидалось:
Option Explicit
Public Function testF() As String()
Dim Output(1, 1) As String
Output(0, 0) = 1
Output(0, 1) = 2
Output(1, 0) = 3
Output(1, 1) = "String with over 255 letters: There are seven days of the week, or uniquely named 24-hour periods designed to provide scheduling context and make time more easily measureable. Each of these days is identifiable by specific plans, moods, and tones. Monday is viewed by many to be the worst day of the week, as it marks the return to work following the weekend, when most full-time employees are given two days off."
testF = Output
End Function
или
Option Explicit
Public Function testF() As Variant
Dim Output(1, 1) As Variant
Output(0, 0) = 1
Output(0, 1) = 2
Output(1, 0) = 3
Output(1, 1) = "String with over 255 letters: There are seven days of the week, or uniquely named 24-hour periods designed to provide scheduling context and make time more easily measureable. Each of these days is identifiable by specific plans, moods, and tones. Monday is viewed by many to be the worst day of the week, as it marks the return to work following the weekend, when most full-time employees are given two days off."
testF = Output
End Function