VBA мой массив не вставляет значения прямо на лист - PullRequest
0 голосов
/ 13 июля 2020

У меня есть код, который заполняет разные значения в инструменте и помещает ответы в массив. Массив заполняется хорошо, и значения в массиве правильные. Но когда я вставляю значения из массива в лист, не все значения верны. Вот мой код и изображение вывода. Первые 6 строк выглядят так, как должно быть.

Range("F34").Value = 15
Range("F37").Value = 0.5
Range("H56").Value = "Recirculation"

Dim c As LongLong, t As LongLong, m As LongLong
Dim p As String, e As LongLong
Dim MyArray() As String
Dim x As Integer

Application.ScreenUpdating = False
ReDim MyArray(545, 5)
    For c = 5000 To 50000 Step 5000
        For t = 40 To 70 Step 5
            For m = 3 To 8 Step 1
                
                Range("F33").Value2 = c
                Range("F35").Value2 = t
                Range("F36").Value2 = m
                e = Range("L30").Value2
                Range("F214").Value = ""
                Range("F215").Value = ""
                If IsError(Sheets("8. Financial").Range("M87").Value2) Then
                    Get_Fan
                    If IsError(Range("P47").Value2) Then
                        p = "A"
                    Else
                        p = Sheets("8. Financial").Range("M87").Value
                    End If
                Else
                    p = Sheets("8. Financial").Range("M87").Value
                End If
            
                MyArray(x, 0) = c & t & m
                MyArray(x, 1) = c
                MyArray(x, 2) = t
                MyArray(x, 3) = m
                MyArray(x, 4) = p
                MyArray(x, 5) = e
                x = x + 1

            Next m
        Next t
    Next c

x = 420

    For c = 60000 To 80000 Step 10000
        For t = 40 To 70 Step 5
            For m = 3 To 8 Step 1
                
                Range("F33").Value2 = c
                Range("F35").Value2 = t
                Range("F36").Value2 = m
                e = Range("L30").Value2
                Range("F214").Value = ""
                Range("F215").Value = ""
                If IsError(Sheets("8. Financial").Range("M87").Value2) Then
                    Get_Fan
                    If IsError(Range("P47").Value2) Then
                        p = "A"
                    Else
                        p = Sheets("8. Financial").Range("M87").Value
                    End If
                Else
                    p = Sheets("8. Financial").Range("M87").Value
                End If
            
                MyArray(x, 0) = c & t & m
                MyArray(x, 1) = c
                MyArray(x, 2) = t
                MyArray(x, 3) = m
                MyArray(x, 4) = p
                MyArray(x, 5) = e
                x = x + 1

            Next m
        Next t
    Next c

Worksheets("Light table").Range("A2:F547").Value2 = MyArray
Application.ScreenUpdating = True

введите описание изображения здесь

1 Ответ

0 голосов
/ 13 июля 2020
• 1000 Установите Destination = Worksheets ("Light table"). Range ("A2") Destination.Resize (UBound (MyArray, 1), UBound (MyArray, 2)). Value2 = MyArray
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...