snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
rivate Sub CommandButton1_Click()
With Application
.EnableEvents = False
.DisplayAlerts = False
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
With Sheets("MAIN")
[N2] = "X"
For i = 4 To 100
If IsNumeric(Left(Trim(Cells(i, 5).Value), 1)) = True Then
If Cells(i, 13).Value = "" And Cells(i, 5).Value <> "" Then
Cells(i, 13).Value = [B7]
End If
If Trim(Cells(i, 5).Value) Like "123*" Then
If Right(Left(Trim(Cells(i, 5).Value), 3), 2) >= 10 And Right(Left(Trim(Cells(i, 5).Value), 3), 2) <= 13 Then
Cells(i, 13).Value = "A"
End If
If Trim(Cells(i, 5).Value) Like "150****" Then
Cells(i, 13).Value = "B"
End If
End If
End If
Next
[N2] = ""
End With
With Application
.EnableEvents = True
.DisplayAlerts = True
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub