プロが教えるわが家の防犯対策術!

VBAのオートフィルのコードの書き方を教えて頂きたいです。
VBA初心者です。

セルの空白、検索して、オートフィルしたいのですが、
繰り返しでなく、一回だけ、オートフィル止めたい。
例の画像です。
黄色の空白セルにオートフィルを使いたい。
左側から右側に完成するイメージです。
よろしくお願いします。


Sub sample()
Dim xArea As Range
For Each xArea In Range("B2", Cells(Rows.Count, 1).End(xlUp).Offset(, 1)).SpecialCells(xlCellTypeBlanks).Areas
With xArea
.Cells(1).Value = 1
If .Count > 1 Then _
.Cells(1).AutoFill Destination:=.Cells, Type:=xlFillSeries
End With
Next xArea
End Sub

「VBAのオートフィルのコードの書き方を教」の質問画像

A 回答 (1件)

こういう事でしょうか?



Sub sample()

Dim xflg As Boolean

 For Each xArea In Range("B2", Cells(Rows.Count, 1).End(xlUp).Offset(, 1)).SpecialCells(xlCellTypeBlanks).Areas
  With xArea
   .Cells(1).Value = 1
   If .Count > 1 Then
    .Cells(1).AutoFill Destination:=.Cells, Type:=xlFillSeries
    Exit For
   End If
  End With
 Next xArea

End Sub
    • good
    • 0
この回答へのお礼

凄い。本当に助かりました。ありがとうございました。

お礼日時:2019/11/23 08:11

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