79722095

Date: 2025-08-01 05:39:00
Score: 1
Natty:
Report link

I have resolved the issue. Thank you to the people that visited this question. This works fine thank you to someone's post on Reddit that helped push me to the right direction. https://www.reddit.com/r/excel/comments/bgzkbj/vba_dealing_with_no_cells_were_found/

Selection.AutoFilter Field:=2, Criteria1:=DATE_ONE, Operator:=xlAnd, Criteria2:=DATE_TWO
    
    Dim filteredCell As Range
    
    On Error Resume Next
    Set filteredCell = Range("G2", "G" & lastrow).SpecialCells(xlCellTypeVisible)
    On Error GoTo 0
    
    If filteredCell Is Nothing Then
            MsgBox "データが見つかりません。処理を中断します。", vbOKOnly + vbExclamation, "エラー"
            Application.DisplayAlerts = False
            resultWS.Delete
                originC.Worksheet.Parent.Activate
                originC.Worksheet.Activate
                originC.Select
            Application.DisplayAlerts = True
            Exit Sub
    Else
    End If
Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Blacklisted phrase (0.5): thank you
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Anpo Desu