我正在尝试自动隐藏K3到K17为零的行。我发现这个代码是我一直试图篡改去上班但它似乎总是隐藏列中的每个空单元而不是特定范围。
Private Sub Worksheet_Calculate()
Dim LastRow As Long, c As Range
Application.EnableEvents = False
LastRow = Cells(Cells.Rows.Count, ""K"").End(xlUp).Row
On Error Resume Next
For Each c In Range(""K3:K17"" & LastRow)
If c.Value = 0 Then
c.EntireRow.Hidden = True
ElseIf c.Value > 0 Then
c.EntireRow.Hidden = False
End If
Next
On Error GoTo 0
Application.EnableEvents = True
End Sub"
答案 0 :(得分:0)
假设你有单个双引号内的字符串,你循环了很多行:
{
int* __x = new int;
int& x = (*__x);
/////////////////
x = 10;
int* xp = &x;
// now xp == __x
/////////////////
delete __x;
}
For Each c In Range("K3:K17" & LastRow)
是最后一个非空行(在K列中)所以如果它是17,那么你正在做的是
LastRow
我希望修复是显而易见的,但无论如何这是
For Each c In Range("K3:K1717")