snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Sub HideRows()
Dim l As Long
l = [count(a1:a51)]
With ActiveSheet
.Range(.Range("a2").Offset(l, 0), .Range("a51")).EntireRow.Hidden True
End With
End Sub
With ActiveSheet
l = .Range("a" & .Rows.Count).End(xlUp).Row
Do While l > 1
If .Range("a" & l).Value > 0 Then
.Range("a" & l).EntireRow.Hidden = True
End If
l = l - 1
Loop
End With
With ActiveSheet
l = .Range("a" & .Rows.Count).End(xlUp).Row
Do While l > 1
If .Range("a" & l).Value > 0 Then
.Range("a" & l).EntireRow.Hidden = True
End If
l = l - 1
Loop
End With
Sub Calculate()
Application.ScreenUpdating = False
Sheets("Pension").Select
ActiveSheet.Unprotect Password:="11111"
Cells.Select
Range("A4").Activate
Cells.EntireRow.AutoFit
Range("A8:N8").Select
Dim l As Long
l = [count(a10:a59)]
With ActiveSheet
.Range(.Range("a10").Offset(l, 0), .Range("a59")).EntireRow.Hidden = True
End With
ActiveSheet.Protect Password:="11111", Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingRows:=True, _
AllowInsertingRows:=True, AllowSorting:=True, AllowFiltering:=True
Sheets("DataList").Select
ActiveSheet.Unprotect Password:="11111"
Dim lg As Long
lg = [count(BB3:BB1502)]
With ActiveSheet
lg = .Range("BB" & .Rows.Count).End(xlUp).Row
Do While lg > 1
If .Range("BB" & lg).Value > 0 Then
.Range("BB" & lg).EntireRow.Hidden = True
End If
lg = lg - 1
Loop
End With
ActiveSheet.Protect Password:="11111", Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingRows:=True, _
AllowInsertingRows:=True, AllowSorting:=True, AllowFiltering:=True
Sheets("Pol").Select
Application.ScreenUpdating = True
End Sub
Sub HideRows()
With ActiveSheet
l = .Range("a" & .Rows.Count).End(xlUp).Row
Do While l > 1
If .Range("a" & l).Value > 0 Then
.Range("a" & l).EntireRow.Hidden = True
End If
l = l - 1
Loop
End With
End Sub
Sub HideRows()
With ActiveSheet
l = .Range("a" & .Rows.Count).End(xlUp).Row
Do While l > 1
If .Range("a" & l).Value > 0 And .Range("c" & l).Value = 1 Then
.Range("a" & l).EntireRow.Hidden = True
End If
l = l - 1
Loop
End With
End Sub