dポイントプレゼントキャンペーン実施中!

タイトルの通りです。
選択範囲に罫線を引くマクロを作成しました。
外に太い枠線、中は点線を引き、選択範囲の一番上の行を灰色の塗りつぶしにしたいのです。
しかし、罫線はうまくいきましたが、一番上の行の指定がうまくできません。

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

どうすればよいか、もしご存知の方がいらっしゃいましたら、ご指導ください。
よろしくお願いたします。

A 回答 (3件)

お試しください


Sub 罫線をひく2()
  With Selection
    .Borders.LineStyle = xlContinuous
    .Borders.Weight = xlHairline
    .BorderAround Weight:=xlThin
    With .Rows(1).Interior
      .Pattern = xlSolid
      .PatternColorIndex = xlAutomatic
      .PatternThemeColor = xlThemeColorDark1
      .TintAndShade = -0.499984740745262
      .PatternTintAndShade = 0
    End With
  End With
End Sub
    • good
    • 0

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


選択範囲の1行目は
Selection.Rows(1)

Sub 罫線をひく2()
  With Selection
    .Borders.LineStyle = xlContinuous
    .Borders.Weight = xlHairline
    .BorderAround Weight:=xlThin
    With .Rows(1)
      '↓以降は2007の環境が無いので確認できていません
      .Pattern = xlSolid
      .ThemeColor = xlThemeColorDark1
      .TintAndShade = -0.499984740745262
      .PatternTintAndShade = 0
    End With
  End With
End Sub
    • good
    • 0
この回答へのお礼

丁寧に教えて頂きありがとうございます。
私の技術不足かちょっとうまく動きませんでした。
もう少し勉強してみようと思います。まだメソッドとプロパティの意味もよくわかっていないので…汗
ありがとうござました。

お礼日時:2010/04/11 08:21

こんな感じで



selection.cells(1).resize(,selection.columns.count).select

参考まで
    • good
    • 0
この回答へのお礼

ありがとうございます!解決できました。
意味を調べながら勉強しようと思います。

お礼日時:2010/04/11 08:15

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!