簡體   English   中英

收到無效的限定符錯誤。 我正在嘗試借助數組將常用品牌從工作簿打印到另一個

[英]Getting an Invalid Qualifier error. I am trying to print the common brands from a workbook to another with help of an array

運行時的代碼沒有顯示錯誤,但沒有打印任何值:

Sub HouseOfCommons()

Dim filePath As String
filePath = "D:\"
Dim Brands(100) As String
Dim QuesRange(4) As String

QuesRange(0) = "A10:F125"

QuesRange(1) = "A137:F254"

QuesRange(2) = "A266:F307"

QuesRange(3) = "A319:F362"

QuesRange(4) = "A373: F415"

Dim inputx As String
inputx = InputBox("Enter the brand")



For I = 0 To 4
    Workbooks.Open (filePath + "JP_CP_2019Q3_Data Tables.xlsx")
    ActiveWorkbook.Worksheets("P_2_3w").Select
    If (Workbooks("JP_CP_2019Q3_Data Tables.xlsx").Worksheets("P_2_3w").Range("A137:A500").Find(inputx)) = True Then
        If (Brands.Contains(inputx)) = False Then
        Brands.Add (inputx)
        For x = 1 To UBound(Brands)
        Workbooks.Open ("D:\InProcess.xlsm")
        ThisWorkbook.Sheets("Sheet2").Cells.Value(I, 1) = inputx
        Next x
        End If
    End If
Next I

結束子

該代碼應將常見品牌存儲到一個數組中,並將它們打印在一個名為“InProcess.xlsm”的單獨工作簿中

您正在使用 VBA 不支持的 .NET 語法:

If (Brands.Contains(inputx)) = False Then

可能的替換:

If IsError(Application.Match(inputx, Brands, 0)) Then

您的代碼似乎還有其他問題,但在不知道它應該做什么的情況下很難提供建議的修復。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM