返回列表 上一主題 發帖

一個清除斜框線問題

一個清除斜框線問題

大大們,
小弟有一問題, 請大大們協助解決, 現附上檔案, 內有標籤說明, 請大大們協助,
謝謝!
aaa.rar (35.06 KB)

回復 1# 周大偉
關閉事件程序觸發
  1. Sub 清除斜線()
  2. '
  3. ' 清除斜線 Macro
  4. ' shchao 在 2010/11/15 錄製的巨集
  5. '

  6. '
  7. Application.EnableEvents = False
  8.     Range("B15:K34").Select
  9.     Selection.ClearContents
  10.     Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  11.     Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  12.     With Selection.Borders(xlEdgeLeft)
  13.         .LineStyle = xlDouble
  14.         .Weight = xlThick
  15.         .ColorIndex = xlAutomatic
  16.     End With
  17.     With Selection.Borders(xlEdgeTop)
  18.         .LineStyle = xlDouble
  19.         .Weight = xlThick
  20.         .ColorIndex = xlAutomatic
  21.     End With
  22.     With Selection.Borders(xlEdgeBottom)
  23.         .LineStyle = xlContinuous
  24.         .Weight = xlThin
  25.         .ColorIndex = 15
  26.     End With
  27.     With Selection.Borders(xlEdgeRight)
  28.         .LineStyle = xlDouble
  29.         .Weight = xlThick
  30.         .ColorIndex = xlAutomatic
  31.     End With
  32.     With Selection.Borders(xlInsideVertical)
  33.         .LineStyle = xlContinuous
  34.         .Weight = xlMedium
  35.         .ColorIndex = 15
  36.     End With
  37.     With Selection.Borders(xlInsideHorizontal)
  38.         .LineStyle = xlContinuous
  39.         .Weight = xlThin
  40.         .ColorIndex = 15
  41.     End With
  42.     Range("E8:F8").Select
  43.     Application.EnableEvents = True
  44. End Sub
複製代碼
學海無涯_不恥下問

TOP

錄製的代碼是很冗長的,而你的目的只須要一句。
Sub 清除斜線()
    [B15:K34].Borders(6).LineStyle = xlNone
End Sub

TOP

謝謝两位版主大大, 問題已解決, 在此祝願快樂...謝謝!!

TOP

回復 4# 周大偉


    希望在這2個回覆中您能了解幾個重點
1、程式碼中的SELECT會觸發事件程序的解決方法
2、錄製巨集後應去解讀程式碼的意義,才能去蕪存菁減短程式碼,易於日後修正
學海無涯_不恥下問

TOP

Hsieh大大,
衷心謝謝寶貴的意見, 祝願快樂!

TOP

        靜思自在 : 能善用時間的人,必能掌握自己努力的方向。
返回列表 上一主題