snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Dim r As Long, lr As Long, i
Application.ScreenUpdating = False
i = Array("", "OBSERVATIONS", "VIOLATIONS", "TOTAL", "")
lr = Cells(Rows.Count, 1).End(xlUp).Row + 1
For r = lr To 3 Step -1
If Cells(r, 1) <> Cells(r - 1, 1) Then
Rows(r).Resize(5).Insert
Cells(r, 1).Resize(5).Value = Application.Transpose(i)
Cells(r, 1).Resize(, 2).Interior.ColorIndex = 15
Cells(r + 1, 1).Resize(3).Font.Bold = True
Cells(r + 4, 1).Resize(, 2).Interior.ColorIndex = 15
End If
Next r
Columns(1).AutoFit
Application.ScreenUpdating = True
จาก Code ด้านบน สงสัยตรงที่ว่า For r = lr To 3 step -1 หมายความว่าอย่างไรครับ