[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]
『印刷したく無い文字』(ゆたぽん)
非表示ではなくセル又は文字を着色してその色だけ印刷しないと言う事が出来るのでしょうか?(白以外で)
みやほりんが 未解決ログ解消を目的に 2006/04/08 17:40 ごろ、投稿しました。 トピ主の[ゆたぽん]さんの投稿は2004/04/23 14:12:17でした。 標準機能のみで自動で特定色だけ印刷しない、という設定はできないように思えます。 マクロ2種、提案します。どちらもBeforePrintイベントマクロで特定シート、特定 範囲のフォント色「赤」のものをフォント色「白」として印刷するもの。 【1】書式置換を利用。印刷後逆の置換で書式を戻す。 Excel2002以降に対応。 Private Sub Workbook_BeforePrint(Cancel As Boolean) Const MyShName As String = "Sheet1" Const MyRng As String = "A1:D10" Const Mycolor As Long = 3 '赤の色番号 Const White As Long = 2 '白の色番号 If ActiveSheet.Name = MyShName Then Cancel = True With Worksheets(MyShName).Range(MyRng) With Application.FindFormat.Font .ColorIndex = Mycolor End With With Application.ReplaceFormat.Font .ColorIndex = White End With .Replace What:="", Replacement:="", LookAt:=xlPart, SearchOrder:= _ xlByRows, MatchCase:=False, SearchFormat:=True, ReplaceFormat:=True Application.EnableEvents = False Worksheets(MyShName).PrintOut Application.EnableEvents = True With Application.FindFormat.Font .ColorIndex = White End With With Application.ReplaceFormat.Font .ColorIndex = Mycolor End With .Replace What:="", Replacement:="", LookAt:=xlPart, SearchOrder:= _ xlByRows, MatchCase:=False, SearchFormat:=True, ReplaceFormat:=True End With End If End Sub 【2】4.0マクロ関数と条件付書式の組み合わせ。 条件付書式がほかに使われていなければ有効。 Private Sub Workbook_BeforePrint(Cancel As Boolean) Const MyShName As String = "Sheet1" Const MyRng As String = "A1:D10" Const Mycolor As Long = 3 '赤の色番号 Const White As Long = 2 '白の色番号 If ActiveSheet.Name = MyShName Then ThisWorkbook.Names.Add _ Name:="赤", _ RefersToR1C1:="=(GET.CELL(24,!RC)+NOW()*0)=" & Mycolor Cancel = True With Worksheets(MyShName).Range(MyRng) .FormatConditions.Add Type:=xlExpression, Formula1:="=赤" .FormatConditions(1).Font.ColorIndex = White Application.Calculate Application.EnableEvents = False Worksheets(MyShName).PrintOut Application.EnableEvents = True .FormatConditions.Delete End With ThisWorkbook.Names("赤").Delete End If End Sub For Each構文で対象セル全部のフォント色をチェックしてフォントを変更していく、 という手もあります。 (みやほりん)(-_∂)b
[ 一覧(最新更新順) ]
YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki.
Modified by kazu.