snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Sub Exp()
Dim i As Long
Dim l As Long
Dim r As Long
Application.ScreenUpdating = False
Range("M7:P30").ClearContents
l = Range("b" & Rows.Count).End(xlUp).Offset(1, 0).Row
For i = 1 To l
r = Range("n" & Rows.Count).End(xlUp).Offset(1, 0).Row
If LCase(Range("b" & i).Value) = LCase(Range("n6").Value) Then
Range("n" & r).Value = Range("b" & i).Value
Range("m" & r).Value = Range("a" & i).Value
Range("o" & r).Value = Range("c" & i).Value
Range("p" & r).Value = Range("d" & i).Value
End If
Next i
Application.ScreenUpdating = True
End Sub
You do not have the required permissions to view the files attached to this post.
Sub Exp()
Dim i As Long
Dim l As Long
Dim r As Long
Application.ScreenUpdating = False
Range("M7:P30").ClearContents
l = Range("b" & Rows.Count).End(xlUp).Offset(1, 0).Row
For i = 7 To l
r = Range("n" & Rows.Count).End(xlUp).Offset(1, 0).Row
If Range("b" & i).Value = Range("n6").Value And Range("a" & i).Value >= Range("m6").Value Then
Range("n" & r).Value = Range("b" & i).Value
Range("m" & r).Value = Range("a" & i).Value
Range("o" & r).Value = Range("c" & i).Value
Range("p" & r).Value = Range("d" & i).Value
End If
Next i
Application.ScreenUpdating = True
End Sub