snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
ผมจะเช็คว่า Cell ไหนไม่มีค่าแล้วให้โชว์ Msgbox "ERROR + Cell name นั้นๆ" ปัจจุบันผม ใช้ if ทั้งหมด 365 วัน ครับช่วยแนะนำให้ลดปริมาณการใช้ IF หน่อยครับ
Sub check_Data()
Dim OutPut As Integer
If Sheet1.Range("B2").Value <> "OK" Then
OutPut = MsgBox("ERROR DAY1")
End If
If Sheet1.Range("C2").Value <> "OK" Then
OutPut = MsgBox("ERROR DAY2")
End If
End Sub
You do not have the required permissions to view the files attached to this post.
kampanart wrote: Wed Feb 14, 2018 11:15 am
ผมจะเช็คว่า Cell ไหนไม่มีค่าแล้วให้โชว์ Msgbox "ERROR + Cell name นั้นๆ" ปัจจุบันผม ใช้ if ทั้งหมด 365 วัน ครับช่วยแนะนำให้ลดปริมาณการใช้ IF หน่อยครับ
Sub check_Data()
Dim OutPut As Integer
If Sheet1.Range("B2").Value <> "OK" Then
OutPut = MsgBox("ERROR DAY1")
End If
If Sheet1.Range("C2").Value <> "OK" Then
OutPut = MsgBox("ERROR DAY2")
End If
End Sub
Sub check_Data()
Dim OutPut As Integer
Dim i As Integer
For i = 2 To Cells(1, Columns.Count).End(xlToLeft).Column
If Sheet1.Cells(2, i).Value <> "OK" Then
OutPut = MsgBox("ERROR DAY" & i - 1)
End If
Next i
End Sub