• ベストアンサー

セル色を5秒間隔で変える

マクロ作成でセルに色を3色順次に変わるようにしたいのですが、 セル色の変更時間が早く、最後の色のみの表示になります。 コマンドボタンをクリックすると、アクティブセル(B3からF3)までのセル色が黄色・薄青・赤に5秒間隔で変色し、その後、下のセルに移動します。 再度、コマンドボタンをクリックすると、先ほどの上のセルの色が消え、アクティブセルに黄色・薄青・赤に5秒間隔で変更するVBAをお教えください。マクロで作成したVBを表示しておきます。 {timer}を使用するみたいですが、理解出来ませんので、宜しくお願いします。 罫線も引いてあります。 ActiveCell.Range("A1:E1").Select With Selection.Interior Timer = 4 .ColorIndex = 35 .Pattern = xlSolid End With Selection.Interior.ColorIndex = xlNone With Selection.Interior .ColorIndex = 7 .Pattern = xlSolid End With Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With Selection.Borders(xlInsideVertical).LineStyle = xlNone ActiveCell.Offset(1, 0).Range("A1:E1").Select End Sub

質問者が選んだベストアンサー

  • ベストアンサー
  • imogasi
  • ベストアンサー率27% (4737/17068)
回答No.3

こんなのエクセルVBAの使い方(エクセルの使い方)としては懲りすぎだ。エクセルの操作や設定では出来ないことでしょう。そこまで高度に、珍奇にやりたいなら、本来は自分で勉強して、他人の回答に頼らず、やべき範囲の課題と思う。 ーー 質問の意味が1部良くわからない。例えばB-Fの5列を問題にしていてなぜ3色とか。勝手に当方で解釈した下記やってみた。 そういうことから質問者のニーズと外れている恐れもある。 参考になるところがあれば使って。自分の浅才のため、PUBLIC変数を使うところなど気に食わないが。 (1)Sheet1に(Formを介さず)コマンドボタン(コントロールツールボックスの方)を1つ貼り付ける。 (2)コマンドボタンのクリックイベントに下記を貼り付ける。 時刻の制御用。 Private Sub CommandButton1_Click() t = 0 r = ActiveCell.Row Range(Cells(r - 1, "B"), Cells(r - 1, "F")).Interior.ColorIndex = xlNone 指定時刻 = Now() For i = 1 To 5 指定時刻 = 指定時刻 + TimeValue("0時00分05秒") '5秒後 待ち時間 = TimeValue("0時00分05秒") Application.OnTime TimeValue(指定時刻), "test01", TimeValue(待ち時間) Next i End Sub ーー 標準モジュールに (3)パブリック変数 Public t Public r (4)実行モジュールに 定時に実行する処理内容。 Sub test01() Dim c(10) '5色のColorIndexの設定 c(1) = 3: c(2) = 12: c(3) = 5: c(4) = 9: c(5) = 6 t = t + 1 Cells(r, t + 1).Interior.ColorIndex = c(t) End Sub ーーーー 操作と結果の説明(質問もこのように書くべきではとおもう) B5をクリック コマンドボタンをクリック 5秒後にB5が赤、5秒後にC5オウド、5秒後に青・・とF5まで色が付く(C5を色をつけたときB5は色を消すのか質問で良くわからなかったので消してない) B6をクリック コマンドボタンをクリック B5:F5の色を消す B6から、上記B6の場合と同じことを繰り返す。 ーー クリックの5秒後から色付けが始まるが良くないかな。 改良は出来るでしょう。

gorugo48
質問者

お礼

質問の方法をこれから考えます。 いろいろな方法があるものですね。 参考になりました。 有り難うございます。

その他の回答 (4)

  • redfox63
  • ベストアンサー率71% (1325/1856)
回答No.5

>シート側の色変更用の変数を準備します 以降のコードは Sheet1など 色変更をしたいシートモジュールに記述してください

  • onlyrom
  • ベストアンサー率59% (228/384)
回答No.4

No2、onlyromです。 間違いがありです。(^^;;; NO2の回答で 選択範囲は、1行(B2~F2とか)か、又は、1列(E1~E5とか)を想定してある と書きましたが、 正しくは、 同じ行の範囲(B2~F2とか、E5~J5とか)のみ想定してあり 同じ列の範囲(E1~E5とか、B3~B9とか)は想定していません。 ということです。 同じ列の範囲(E1~E5とか、B3~B9とか)も想定するとコードが数行増えることになります。 所望ならアップします。 以上。  

  • onlyrom
  • ベストアンサー率59% (228/384)
回答No.2

>アクティブセル(B3からF3)までのセル色が黄色・薄青・赤に5秒間隔で変色し この意味がよく理解できません。 アクティブセルというのは、ひとつのセルのことです。  たぶん、こういうことでしょうね? ある範囲、例えば、B3:F3 を選択した後、 コマンドボタンをクリックすると 選択範囲(B3~F3)のセルを順番に5秒間隔で塗りつぶしていく 再度、ボタンをクリックしたら、 前回塗りつぶしたセルは色なしにし、次の行を同じく塗りつぶしていく これだけであれば、Waitメソッドが分かり易いかもしれません。 「コントロールツールボックス」の中のコマンドボタンをシートに配置 '--------------------------------------------------- Private Sub CommandButton1_Click()  Dim Rng As Range  Dim N As Integer  Dim myColor  myColor = Array(3, 6, 8)  '●色番号  If Selection.Cells(1).Row > 1 Then    Selection.Offset(-1).Interior.ColorIndex = xlNone  End If  For Each Rng In Selection.Cells    Rng.Interior.ColorIndex = myColor(N)    Application.Wait Now + TimeValue("0:00:05")    N = N + 1    If N > 2 Then N = 0  Next Rng  Selection.Offset(1).Select End Sub '-------------------------------------------- セル範囲を選択した後、ボタンをクリックして実行すること 選択範囲は、1行(B2~F2とか)か、又は、1列(E1~E5とか)を想定してある 色は、「赤、青、水色」にしてある 以上。  

  • redfox63
  • ベストアンサー率71% (1325/1856)
回答No.1

ExcelVBAの場合 Timerオブジェクトは無いので Applicationクラスの OnTimeメソッドを使います 標準モジュールを追加して タイマーで起動されるプロシージャを定義します Public Sub myChange()   '実際に背景色を変更するシートのプロシージャを呼ぶ   Sheet1.ColorChange() End Sub シート側の色変更用の変数を準備します Dim bFlag as Boolean Dim cl as integer DIm myDt as Date シート側に実際に実行するプロシージャを定義します Public Sub ColorChange()   ' 塗りつぶしの設定のみしています   ' セルの選択範囲もActiveCellのみです   ' 適宜修正してください   ActiveCell.Interior.ColorINdex = cl   if bFlag then     myDt = Now + Timevalue("0:0:5")   end if   Select Case cl   case 3     cl = 35   case 35     cl = 7   case 7     cl = 0   case else     ActiveCell.Offset(1,0).Select     myDt = Now   End Select   if bFlag then     Application.OnTime myDt, "myChange"   End if End Sub コマンドボタンのClickイベントに Private Sub CommandButton1_Click()   If bFlag = False Then     cl = 3     bFlag = True     Application.OnTime Now, "myChange"   Else     bFlag = False     Application.OnTime myDt, "myChange", , False End If End Sub とします コマンドボタンをクリックすると色変更が始まります もう一度クリックすると停止します

gorugo48
質問者

補足

redfox63様。 早速のご教授有り難うございます。 VBAが不慣れの為、再度質問指して頂きます。 すべて同じ標準モジュールにコピー指して頂きました。 「コマンドボタンのClickイベン」とありますが、同じ標準モジュールでよろしいのでしょうか。記入方法をお願いします。 Public Sub myChange()   '実際に背景色を変更するシートのプロシージャを呼ぶ   Sheet1.ColorChange()ここの位置が反転します。()も必要でしょうか。 End Sub 操作しますと コマンドボタンで下方向に移動はしますが、色がつきません。 何か間違っているのでしょうか。 宜しくお願いします。

関連するQ&A

  • このマクロコードをダイエットするには?

    罫線を引き、配色し、文字に色を付ける。 このコードをどのようにダイエットすればよいのでしょうか? 罫線のマクロはこんなに大きいのですか? Withの使い方がよくわかりません。 よろしくお願い致します。 ------------ Sub Test1() Range("B1:O14").Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlHairline .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlHairline .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlHairline .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlHairline .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlHairline .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlHairline .ColorIndex = xlAutomatic End With With Selection.Interior .ColorIndex = 56 .Pattern = xlSolid End With Selection.Font.ColorIndex = 33 End Sub

  • VBAで表作成

    こんにちわ VBAを使い表を作っているのですが、入力フォームで日付を入力しコマンドボタンを押すと別ブックになり、予め用意してある表に入力した日付から1ヶ月の日付が貼り付けるというのをやっています。 マクロを記録し試してみたところ構文エラーが出てしまいました。 日付を貼り付けるところまでできたのですが・・・ 表には線がすでに入っています。 入力された最後の日付のところで太線で表を閉めたいのですができますでしょうか。 構文エラーになったソースを貼り付けます。 Range((4,"i"+12):(10,"i"+12)).Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlHairline .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With よろしくお願いします

  • 表に罫線を最終列まで引きたい

    windows7 とExcel2007でマクロ作成中の初心者です。 最初に、D2:E34を選んで罫線をひき、列を2列移動して、また罫線を引きます。 これをデータのある最終列まで繰り返したいのですが、うまくいきません。 どうしたらよろしいでしょうか。 Sub 勤怠に罫線() Dim n As Integer For n = 1 To 5 勤怠に罫線 Selection.Offset(0, 2).Select 勤怠に罫線 Next n End Sub 以下はマクロの自動記録でコードを書きました。 Sub 勤怠に罫線() Range("D2:E34").Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .ColorIndex = xlAutomatic .TintAndShade = 0 .Weight = xlMedium End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .ColorIndex = xlAutomatic .TintAndShade = 0 .Weight = xlMedium End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .ColorIndex = xlAutomatic .TintAndShade = 0 .Weight = xlMedium End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .ColorIndex = xlAutomatic .TintAndShade = 0 .Weight = xlMedium End With Selection.Borders(xlInsideVertical).LineStyle = xlNone Selection.Borders(xlInsideHorizontal).LineStyle = xlNone Range("D2:E34").Select End Sub

  • ワークシートのセルの書式設定の罫線をマクロでひく。

    ワークシートのセルの書式設定の罫線をマクロでひく。 下記マクロを実行すると  (1)のところでBORDERクラスのlinestyle プロパティを設定できません。がでる対策をおしえてください。 Sub Macro1() ' Dim d As Long Sheets("abc").Select '罫線を引く d = Range("A65536").End(xlUp).Row Range("A1", Cells(d, 1)).Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous  ‘(1) .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With End Sub

  • エクセルVBA 行列の数を指定して罫線を引くマクロ教えてください

    下のようにSheet1に罫線を引く「開始セル(左右端)」「行」「列」が書いてあります。 この条件で罫線をSheet2に引くようにしたいのですが、変数の設定の仕方などが分かっていないようで、できません。教えていただけないでしょうか。マクロの記録をとったところ、下のようになりました。よろしくお願いします。 開始セル Sheet2!A1・・・Sheet1のB1セル 行 8・・・Sheet1のB2セル 列 2・・・Sheet1のB3セル Sub borders() Range("A1:B8").Select Selection.borders(xlDiagonalDown).LineStyle = xlNone Selection.borders(xlDiagonalUp).LineStyle = xlNone With Selection.borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With End Sub

  • このマクロを高速化させるにはどうすればいいですか?

    VBA初心者で、とりあえず頑張って作ってみました。以下のVBAでの修正点を教えてください。 (英単語の小テスト用につくりました。) Range("C3:E22,H3:J22").Select Selection.Font.ColorIndex = 2 Selection.Interior.ColorIndex = 2 Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone Selection.Borders(xlEdgeLeft).LineStyle = xlNone Selection.Borders(xlEdgeTop).LineStyle = xlNone Selection.Borders(xlEdgeBottom).LineStyle = xlNone Selection.Borders(xlEdgeRight).LineStyle = xlNone Selection.Borders(xlInsideVertical).LineStyle = xlNone Selection.Borders(xlInsideHorizontal).LineStyle = xlNone Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone ' ここまでは、共通の動作 Range("A1").Select ActiveCell.FormulaR1C1 = "20" ' 問題数に応じて、数字を変更 Range("C3:E22,H3:J22").Select With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With ' 罫線を引く Range("D3:E22,I3:J22").Select Selection.Font.ColorIndex = 1 ' 文字を黒くする Range("C3:C22,H3:H22").Select Selection.Interior.ColorIndex = 16 ' セルをグレーにする Rows("3:18").Select Selection.RowHeight = 31.5 ' セルの幅を指定 ActiveSheet.PageSetup.PrintArea = "$B$1:$K$25" ' 印刷範囲を指定 Range("U3:U42").Select Selection.ClearContents ' 四線を消去 Range("D3:D4").Select Calculate ' 再計算完了 宜しくお願いします。 また、このVBAは慣れている人から見ると何点くらいですか?(感覚で結構です)

  • 選択範囲に黒の格子を付けるマクロ

    マクロ記録をつかって、選択している範囲に黒の格子を付けるマクロをボタンを作成しました。 (質問の下に、記録した内容を添付します) 実際に、格子を作るのには不要な行がたくさんあると思うのですが、不要な箇所をどう見つければいいのか教えてください。 個人的には、with以下の構文は標準設定しているだけなので不要かと思うのですが、何度も設定されていてくどく感じられます。 記録した後に、一括してこれらの記録を消す方法があればあわせて教えてください。 --- Sub 格子マクロ() Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With End Sub

  • エクセルでデータがある部分だけ罫線で囲いたいです。

    エクセルでデータがある部分だけ罫線で囲いたいです。 エクセルのファイルを開いて、データのある部分だけを罫線で囲みたいです。 データーは常に列数も行数も違います。 マクロの記録で行ったら、以下のようになりました。 もう少し短い文章ではできないでしょうか? Sub Macro1() ' ' Macro1 Macro ' マクロ記録日 : 2010/9/22 ' Range("A1").Select Range(Selection, Selection.End(xlToRight)).Select Range(Selection, Selection.End(xlDown)).Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With End Sub

  • VBA 選択範囲の中で、更に一番上の行を指定したい!

    タイトルの通りです。 選択範囲に罫線を引くマクロを作成しました。 外に太い枠線、中は点線を引き、選択範囲の一番上の行を灰色の塗りつぶしにしたいのです。 しかし、罫線はうまくいきましたが、一番上の行の指定がうまくできません。 Sub 罫線をひく() ' With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .ColorIndex = xlAutomatic .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .ColorIndex = xlAutomatic .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .ColorIndex = xlAutomatic .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .ColorIndex = xlAutomatic .TintAndShade = 0 .Weight = xlThin End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .ColorIndex = xlAutomatic .TintAndShade = 0 .Weight = xlHairline End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .ColorIndex = xlAutomatic .TintAndShade = 0 .Weight = xlHairline End With ActiveWindow.SmallScroll Down:=12  ←ここを変えたいのですが、どうすればよいかわかりません。 With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorDark1 .TintAndShade = -0.499984740745262 .PatternTintAndShade = 0 End With End Sub どうすればよいか、もしご存知の方がいらっしゃいましたら、ご指導ください。 よろしくお願いたします。

  • Excel2003枠を作るマクロ

    右側に空白の行を一つつくって枠を作りたいです。 たとえば、G100が一番右下とするとH100まで枠を作りたいのですが、きれいにかくにはどうしたらよいでしょうか? マクロ記録でやると、下のようになるのですが右下が100で有るとは限らないのでその行を定義する必要があると思うのですが、そのあたりがさっぱりわかりません。 よろしくお願いいたします。 Sub Macro1() Selection.End(xlDown).Select Range("H100").Select Range(Selection, Selection.End(xlUp)).Select Range(Selection, Selection.End(xlToLeft)).Select Range(Selection, Selection.End(xlToLeft)).Select Range(Selection, Selection.End(xlToLeft)).Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With End Sub

専門家に質問してみよう