連続データを入力する(AutoFill メソッド)
AutoFill メソッド
Excel で、連続するデータを入力する「オートフィル」機能を VBA で実行します。
【書式】
object.AutoFill ( destination [, type ] )
引数・戻り値
- object ・・・ 対象となる Range オブジェクトを指定します。
- destination ・・・ 連続データの書き込み先となるセル範囲(Range オブジェクト)を指定します(省略不可)。
- type ・・・ オートフィルの種類を表す XlAutoFillType 列挙型 の定数またはその値を指定します(省略可能)。
名前 値 説明 xlFillDefault 0 Excel が決定(既定値) xlFillCopy 1 値と形式 xlFillSeries 2 連続する数値(たとえば、’1, 2′ は ‘3, 4, 5’ となります) xlFillFormats 3 書式のみ xlFillValues 4 値のみ xlFillDays 5 曜日名 xlFillWeekdays 6 平日の名前 xlFillMonths 7 月 xlFillYears 8 年 xlLinearTrend 9 加算による連続データ xlGrowthTrend 10 乗算による連続データ xlFlashFill 11 前のユーザー アクションの検出されたパターンに基づいた値(Excel 2013 以降)
AutoFill メソッド 使用例
サンプルVBAソース
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
Sub Sample_AutoFill() 'Type:省略(Excelが自動判定) Range("A2:A4").AutoFill Destination:=Range("A2:A16") 'Type:連続 Range("B2").AutoFill Destination:=Range("B2:B16"), _ Type:=xlFillSeries 'Type:曜日 Range("C2").AutoFill Destination:=Range("C2:C16"), _ Type:=xlFillDays 'Type:書式のみ Range("D2").AutoFill Destination:=Range("D2:D16"), _ Type:=xlFillFormats 'Type:Excelが自動判定 Range("E3").AutoFill Destination:=Range("E3:E16"), _ Type:=xlFillDefault End Sub |
実行結果
サンプルVBAソース 実行前
実行後
関連記事
-
-
コメントの設定(Comments, Comment, AddComment, ClearComment)
コメントの設定 セルにコメントを新規に挿入するには、AddComment メソッ …
-
-
セルが選択されているか確認する(TypeName 関数)
セルが選択されているか確認する方法と使用例 TypeName 関数の引数に、Se …
-
-
セルをアクティブにする・セルを選択する(Activate, Select)
セルをアクティブにする・選択する 【書式:セルをアクティブにする】 object …
-
-
対象のセルを直接参照しているセル全てを取得(DirectDependents プロパティ)
DirectDependents プロパティ DirectDependents …
-
-
次の検索(FindNext メソッド,FindPrevious メソッド)
FindNext メソッド Find メソッドで開始された検索を継続します。引数 …
-
-
オートフィルタの設定と解除(AutoFilter メソッド)
AutoFilter メソッド オートフィルタを設定する場合、AutoFilte …
-
-
入力規則(他セルや数式を利用して許容値を設定)Validation オブジェクト
他のセルや数式を利用して許容値を設定する 入力規則(その5) での設定を、マクロ …
-
-
文字の向きを表す値を取得・設定する(Orientation プロパティ)
Orientation プロパティ Orientation プロパティで、文字列 …
-
-
オートフィルタ(AutoFilter メソッド)
AutoFilter メソッド 【書式】 object.AutoFilter ( …
-
-
オートフィルタの状況を確認(AutoFilterMode, FilterMode)
AutoFilterMode プロパティ AutoFilterMode プロパテ …

