无法让我的宏识别单元格值

时间:2017-11-23 05:48:54

标签: excel vba excel-vba

在下面的脚本中,它会扫描工作表并提取值,删除不符合“" M"”列中设置条件的值。如果我修改了标准(在下面的#34; MIGS不可用"),我可以让它工作,但是如果我尝试将它作为标准重新引用到单元格(AI1),它可以拉出每条记录或者没有。

您的帮助请允许它将单元格中的值视为脚本中的条件!

Sub QuickCombine_MIGS()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim rng1 As Range
Dim strShts()
Dim strWs As Variant
Dim lngCalc As Long

With Application
.ScreenUpdating = False
lngCalc = .Calculation
.Calculation = xlCalculationManual
End With

Set ws1 = Sheets("MIGS-Datasheet")
ws1.UsedRange.Cells.Clear
strsub = Sheets("MIGS").Range("AI2").Value
strsub2 = Sheets("MIGS").Range("AI1").Value
strShts = Array(strsub)
For Each strWs In strShts
On Error Resume Next
Set ws2 = Sheets(strWs)
On Error GoTo 0
If Not ws2 Is Nothing Then
Set rng1 = ws2.Range(ws2.[v8], ws2.Cells(Rows.Count, "v").End(xlUp))
rng1.EntireRow.Copy ws1.Cells(ws1.Cells(Rows.Count, "v").End(xlUp).Offset(1, 0).Row, "A")
End If
Set ws2 = Nothing
Next
With ws1
    .[v1] = "dummy"
    .Columns("M").AutoFilter Field:=1, Criteria1:="<>MIGS Unavailable"
    .Rows.Delete
.Rows("1").Insert
End With
With Application
.ScreenUpdating = True
.Calculation = lngCalc
End With
End Sub

0 个答案:

没有答案