返回列表 上一主題 發帖

隱藏

本帖最後由 GBKEE 於 2010-6-17 08:04 編輯

回復 1# myleoyes
  1. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  2.      Select Case Target(1).Address(0, 0)
  3.         Case "A1"
  4.             欄
  5.         Case "B1"
  6.             列
  7.     End Select
  8.     If Not Intersect(Target(1), Range("C13:C" & Rows.Count)) Is Nothing Then
  9. 'Love10 同理
  10.     If Target(1).Column = 3 And Target(1) <> "" Then 隱藏
  11.     End If
  12. End Sub

  13. ''''''''''''''''''''''''''''''''''''''''''''''''''''
  14. Sub 隱藏()
  15.     Dim R
  16.     R = (ActiveCell.Row Mod 12)
  17.     If R = 0 Then
  18.         R = ActiveCell.Row - 11 & ":" & ActiveCell.Row
  19.     Else
  20.         R = ActiveCell.Row - R + 1 & ":" & ActiveCell.Row + (12 - R)
  21.     End If
  22.     Rows("13:" & Rows.Count).EntireRow.Hidden = True
  23.     Rows(R).EntireRow.Hidden = False
  24. End Sub
  25. ''''''''''''''''''''''''''''''''''''''''''''''''''''
  26. Sub 差異部份還原()
  27.     Dim R
  28.     R = (ActiveCell.Row Mod 12)
  29.     If R = 0 Then
  30.         R = "C" & ActiveCell.Row - 11 & ":IV" & ActiveCell.Row
  31.     Else
  32.         R = "C" & ActiveCell.Row - R + 1 & ":IV" & ActiveCell.Row + (12 - R)
  33.     End If
  34.     Range(R).Copy Sheet11.[C65536].End(xlUp).Offset(0, 0)
  35.     Sheet11.Select
  36. End Sub
複製代碼

TOP

回復 4# myleoyes
  1. Sub 隱藏()
  2.     Dim R
  3.     R = (ActiveCell.Row Mod 12)
  4.     If R = 2 Then
  5.          R = ActiveCell.Row - R + 1 & ":" & ActiveCell.Row + (12 - R)
  6.         Rows("13:" & Rows.Count).EntireRow.Hidden = True
  7.         Rows(R).EntireRow.Hidden = False
  8.     End If
  9. End Sub
複製代碼
  1. Sub 差異部份還原()
  2.     Dim R, Rng As Range
  3.     R = (ActiveCell.Row Mod 12)
  4.     If R = 0 Then
  5.         R = "C" & ActiveCell.Row - 11 & ":IV" & ActiveCell.Row
  6.     Else
  7.         R = "C" & ActiveCell.Row - R + 1 & ":IV" & ActiveCell.Row + (12 - R)
  8.     End If
  9.     Set Rng = Sheet11.[C65536].End(xlUp).Offset(1)
  10.     If Sheet11.[C65536].End(xlUp).Row = 1 Then Set Rng = Sheet11.[C65536].End(xlUp)
  11.     Range(R).Copy Rng
  12.     Sheet11.Select
  13. End Sub
複製代碼

TOP

回復 6# victorl
   Target.Cells(1) = ActiveCell
   Target = Selection

TOP

回復 8# myleoyes
  1. Sub 多重選取()
  2.     Dim R, A As Range
  3.     Rows("3:" & Rows.Count).EntireRow.Hidden = True
  4.     '隱藏的範圍內如有任何的物件則 -> .Hidden = True 會產生錯誤
  5.    'Sheets("差異備份")第2列的列高 請調高一些 或 [取消] 按鈕 上移 OR 縮小
  6.    '否則 執行上面程式碼會產生錯誤
  7.     For Each A In Selection.Areas  '選取C16+C40+...的範圍
  8.         If A.Row <= 14 Then
  9.             R = 3 & ":" & 14
  10.         Else
  11.             R = Int((A.Row - 3) / 12)
  12.             R = 3 + (12 * R) & ":" & 3 + (12 * (R + 1)) - 1
  13.         End If
  14.         Rows(R).EntireRow.Hidden = False
  15.     Next
  16. End Sub
複製代碼

TOP

        靜思自在 : 有願放在心裡,沒有身體力行,正如耕田不播種,皆是空過因緣。
返回列表 上一主題