VBA Excel搜索范围中的值并隐藏行(如果找到)
我得到错误VBA Excel搜索范围中的值并隐藏行(如果找到),excel,vba,Excel,Vba,我得到错误类型不匹配 我在这里做矩阵,如果一行包含“x”,那么代码应该保持一行可见。应隐藏没有“x”的行。变量hideEmptyRows从按钮触发 If (hideEmptyRows = True) Then For i = 8 To lastRow If Range(Cells(i, 3), Cells(i, lastColumn)).value = "x" Then cell.EntireRow.Hidden = T
类型不匹配
我在这里做矩阵,如果一行包含“x”
,那么代码应该保持一行可见。应隐藏没有“x”
的行。变量hideEmptyRows
从按钮触发
If (hideEmptyRows = True) Then
For i = 8 To lastRow
If Range(Cells(i, 3), Cells(i, lastColumn)).value = "x" Then
cell.EntireRow.Hidden = True
End If
Next i
End Ifenter code here
类型为
Range
的对象没有Value
这样的属性。您需要在整个范围内循环,以检查该范围内是否有任何单元格的值为“x”
您应该在代码中添加:
ifContains = false ' variable, which indicates if the value is present in current row
For j = 3 To lastColumn
If Cells(i, j).Value = "x" Then
ifContains = true
End If
Next j
谢谢你,伙计!在你的提示下,我继续我的工作。