Avatar of Peter Chan
Peter Chan
Flag for Hong Kong

asked on 

Problem to the message

Hi,
It is strange that, it is showing the message by 'Msgbox' below, while the 2nd and 3rd Debug.print is not showing anything below.
        With Worksheets("Main Sheet").Range(copyRange)
            Set c = .Find(Month0, LookIn:=xlValues)
            Debug.Print Month0
            If Not c Is Nothing Then
            Debug.Print "xc" & CStr(c.Row)
            Debug.Print Format(Worksheets("Main Sheet").Cells(c.Row, 8).Value, "yyyy/MM") & "mm" & Format(Worksheets("Month Status").Cells(i, 4).Value, "yyyy/MM")
            If Trim(Format(Worksheets("Main Sheet").Cells(c.Row, 8).Value, "yyyy/MM")) <> "" Then
            If Format(Worksheets("Main Sheet").Cells(c.Row, 8).Value, "yyyy/MM") = Format(Worksheets("Month Status").Cells(i, 4).Value, "yyyy/MM") Then
                MsgBox "You cannot copy record of a closed month.", vbExclamation, "Month is closed!"
                Exit Sub
                
            End If
            End If
            End If
    
        End With

Open in new window

Visual Basic ClassicVB ScriptVBAMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Qlemo

8/22/2022 - Mon