返回列表 上一主題 發帖

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

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

本帖最後由 hank10459 於 2014-3-3 12:07 編輯

各位 EXCEL神人您好,想請問我現在做這個圖,如果分為2個活頁(03BAY與04(05)BAY),當04BAY有資料時,03BAY的對應位置變成打一個大叉叉,不知有無高手有無辦法可用呢? 如果有看不懂得小弟會再多做說明。 謝謝
如圖為我想變成的這樣。

Q1.gif (24.94 KB)

Q1.gif

回復 1# hank10459

兩個方法可能做到你要的:

1.使用名稱

2.使用indirect來處理你要格式化的條件參照。

請參考這裡:
http://tw.knowledge.yahoo.com/question/question?qid=1512071307819

TOP

回復 2# seer_et
您好S大,目前我的格是也沒辦法用到那種X圖示說!請問有辦法可以給他打上大叉叉嗎?

TOP

回復 1# hank10459

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

TOP

回復 4# sunnyso
回神人S, 我已經上船圖表^^麻煩您囉 Q1.rar (16.84 KB)

TOP

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

TOP

本帖最後由 hank10459 於 2014-3-5 11:31 編輯

回復 6# sunnyso
S大,您好我有看到您的回覆,但因為我LEVEL不夠...可否E-MAIL給我呢。我的信箱是hank9717203@gmail.com    謝謝S大

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

回復 8# sunnyso


    收到了S大。謝謝您的提供。

TOP

回復 5# hank10459
格式化條件是無法控制斜線的格線
既然用VBA輔助,可以簡單一點
03BAY工作表模組程式碼
  1. Private Sub Worksheet_Activate()
  2. Dim r&, k&, i%
  3. With Sheets("(04)05BAY")
  4. For k = 3 To 33 Step 3 'C欄到AG欄,間隔3欄循環
  5.    For r = 4 To 26 Step 3 '第4列到26列,間隔3列循環
  6.       If Application.CountA(.Cells(r, k).Resize(3, 3)) = 7 Then '如果全部填滿
  7.          With Cells(r, k).Resize(3, 3)
  8.             .Merge '合併儲存格
  9.             For i = 5 To 6
  10.                With .Borders(i) '畫斜線
  11.                   .LineStyle = xlContinuous
  12.                End With
  13.             Next
  14.           End With
  15.           Else '否則執行複製貼上、清除內容
  16.           .Cells(r, k).Resize(3, 3).Copy Cells(r, k): Cells(r, k).Resize(3, 3) = ""
  17.        End If
  18.     Next
  19. Next
  20. End With
  21. End Sub
複製代碼
學海無涯_不恥下問

TOP

        靜思自在 : 人事的艱難與琢磨,就是一種考驗。
返回列表 上一主題