Page 1 of 1

ตรวจสอบเซลล์ว่างที่มี formula if cell="" (VBA)

Posted: Mon Feb 07, 2022 12:06 pm
by Pavarisa Y.
ให้ตรวจสอบว่า หากพบเซลล์ว่าง (ซึ่งในเซลล์มีสูตร if cell="" อยู่ในนั้น) จะให้ลบ Range ที่เลือก แล้ว Offset ลงไปทีละ 7 ขั้น
แต่มันขึ้น Error ตลอดเลยค่ะ

Code: Select all

Sub RemoveLayer()
Dim i As Integer
For i = 0 To 10
Range("C15").Offset(i * 7, 0).Activate
        If Selection.Value <> i + 1 Then
        Range("A13:AP19").Offset(i * 7, 0).Select
        With Selection.Interior
            Selection.ClearContents
            Selection.Borders(xlDiagonalDown).LineStyle = xlNone
            Selection.Borders(xlDiagonalUp).LineStyle = xlNone
            Selection.Borders(xlEdgeLeft).LineStyle = xlNone
            Selection.Borders(xlEdgeTop).LineStyle = xlNone
            Selection.Borders(xlEdgeBottom).LineStyle = xlNone
            Selection.Borders(xlEdgeRight).LineStyle = xlNone
            Selection.Borders(xlInsideVertical).LineStyle = xlNone
            Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        .Pattern = False
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
        Selection.FormatConditions.Delete
        ActiveSheet.ClearCircles
        Selection.UnMerge
    End If
Next i
End Sub

Re: ตรวจสอบเซลล์ว่างที่มี formula if cell="" (VBA)

Posted: Mon Feb 07, 2022 1:36 pm
by logic
แนบไฟล์เอ็กเซลมาเลยดีกว่า เพื่อน ๆ จะพอช่วยได้บ้างครับ