返回列表 上一主題 發帖

[發問] 請問有無神人可幫解決這格式化條件的問題

回復 1# hank10459

上個附件, 帶有你公式等. 我來解決X的問題
ss

TOP

Sonny.gif Q1-Sonny.rar (20.9 KB) 回復 5# hank10459
ss

TOP

回復 7# hank10459

here is the code.
  1. Private Sub Worksheet_Activate()

  2. With Sheets(2)
  3.     blnk = .[R4] <> "" Or .[R5] <> "" Or .[R6] <> "" _
  4.         Or .[S5] <> "" Or .[S6] <> "" _
  5.         Or .[T5] <> "" Or .[T6] <> ""
  6. End With


  7. If blnk Then
  8.         Range("R4:T6").Select
  9.     With Selection
  10.         .WrapText = False
  11.         .Orientation = 0
  12.         .AddIndent = False
  13.         .ShrinkToFit = False
  14.         .ReadingOrder = xlContext
  15.         .MergeCells = True
  16.     End With
  17.     With Selection.Borders(xlDiagonalDown)
  18.         .LineStyle = xlContinuous
  19.         .ColorIndex = xlAutomatic
  20.         .TintAndShade = 0
  21.         .Weight = xlMedium
  22.     End With
  23.     With Selection.Borders(xlDiagonalUp)
  24.         .LineStyle = xlContinuous
  25.         .ColorIndex = xlAutomatic
  26.         .TintAndShade = 0
  27.         .Weight = xlMedium
  28.     End With
  29.     With Selection.Borders(xlEdgeLeft)
  30.         .LineStyle = xlContinuous
  31.         .ColorIndex = xlAutomatic
  32.         .TintAndShade = 0
  33.         .Weight = xlMedium
  34.     End With
  35.     With Selection.Borders(xlEdgeTop)
  36.         .LineStyle = xlContinuous
  37.         .ColorIndex = xlAutomatic
  38.         .TintAndShade = 0
  39.         .Weight = xlMedium
  40.     End With
  41.     With Selection.Borders(xlEdgeBottom)
  42.         .LineStyle = xlContinuous
  43.         .ColorIndex = xlAutomatic
  44.         .TintAndShade = 0
  45.         .Weight = xlMedium
  46.     End With
  47.     With Selection.Borders(xlEdgeRight)
  48.         .LineStyle = xlContinuous
  49.         .ColorIndex = xlAutomatic
  50.         .TintAndShade = 0
  51.         .Weight = xlMedium
  52.     End With
  53.     Selection.Borders(xlInsideVertical).LineStyle = xlNone
  54.     Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
  55. Else
  56.     Range("O4:Q6").Select
  57.     ActiveWindow.SmallScroll Down:=-6
  58.     Selection.Copy
  59.     Range("R4").Select
  60.     Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
  61.         SkipBlanks:=False, Transpose:=False
  62.     Application.CutCopyMode = False
  63.     Range("F4:H6").Select
  64.     Selection.Copy
  65.     Range("U4:W6").Select
  66.     Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
  67.         SkipBlanks:=False, Transpose:=False
  68.     Application.CutCopyMode = False

  69. End If


  70. End Sub
複製代碼
ss

TOP

        靜思自在 : 修行要繫緣修心,藉事練心,隨處養心。
返回列表 上一主題