简体   繁体   English

为什么我在这个数组的 VBA 脚本上出现不匹配错误?

[英]why am I getting a mismatch error on this VBA Script for an array?

Fairly new to Arrays (im trying to speed up a currently slow workbook that uses ranges)数组相当新(我试图加快当前使用范围的缓慢工作簿)

lets say I start out with a table like this (Located in Range "A1:B5" on my worksheet)假设我从这样的表格开始(位于工作表上的“A1:B5”范围内)

在此处输入图像描述

and im trying to filter it to only intact (this is a simplified version of what im trying to do irl), why am I getting a Type Mismatch and my output array highlighting?并且我试图将其过滤为仅完好无损(这是我尝试做的事情的简化版本),为什么我得到一个类型不匹配并且我的输出数组突出显示?

Public Sub Manager_Report()
 
 'Declare Variables
 
 Dim main_array As Variant Dim output_array As Variant
 
 'Populate Main Array
 
 main_array = range("A1").CurrentRegion
 
 'Filter the Array for intact 
  output_array = Filter(main_array, "Intact")
 
End Sub
Option Explicit
Option Base 1
Sub OutputFilterArray()
    
    Dim INarray
    Dim OutArray
    Dim OutArrayFinal
    Dim I As Long
    Dim CNT As Long
    Dim N As Integer
    
    INarray = Range("A3:d" & Range("d" & Rows.Count).End(xlUp).Row).Value
    CNT = 1
    
    ReDim OutArray(UBound(INarray, 1), UBound(INarray, 2))
    For I = 1 To UBound(INarray, 1)
        If INarray(I, 1) = "Intact" Then
            For N = 1 To UBound(INarray, 2)
                OutArray(CNT, N) = INarray(I, N)
            Next N
            CNT = CNT + 1
        End If
    Next I
    
    Range("F3").Resize(UBound(OutArray, 1), UBound(OutArray, 2)) = OutArray
    
End Sub

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么会出现“ .class”预期错误? 简单数组脚本 - Why am I getting a '.class' expected error? Simple Array script 在 VBscript 中,尝试将数组列表中的每个项目拆分为单个数组时出现类型不匹配错误 - In VBscript I am getting a type mismatch error when trying to split each item in an array list into a single array 即使类型似乎匹配,为什么还会出现类型不匹配错误? - Why am I getting a type mismatch error even though the types seem to match? Excel VBA: Why am I getting a run-time error 438 when adding custom class object into custom class array? - Excel VBA: Why am I getting a run-time error 438 when adding custom class object into custom class array? 我正在尝试返回一个双精度数组并得到类型不匹配 - I am trying to return an array of doubles and getting a type mismatch 为什么会出现此错误?(双数组方法) - Why am i getting this error?(Double Array Method) 为什么我得到这个数组到字符串转换错误? - Why am I getting this array to string conversion error? 为什么在此代码中出现数组超出范围错误? - Why am I getting an array out of range error in this code? 为什么在遍历(有时为空)变体时会出现(运行时错误“13”:)类型不匹配? - Why am I getting (run-time error '13': ) type mismatch when looping across a (sometimes-empty) variant? 为什么我最后得到空白数组? - Why i am getting blank array at end?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM