ソースシートから4行ごとにセルを参照し、出力シートに配置するにはどうすればよいですか?各セルには異なる値があります。事前にありがとうExcel VBA - インクリメント付きループ
答えて
これは仕事をする必要があります。ワークブックで試す前に、必要なカスタマイズを行ってください。
Sub TransferData()
Dim WsS As Worksheet, WsT As Worksheet ' Source & Target
Dim Rl As Long ' Last row
Dim Rs As Long, Cs As Long ' Source: Row, Column
Dim Rt As Long, Ct As Long ' Target: Row, Column
Set WsS = Worksheets("Source") ' change name as required
Set WsT = Worksheets("Source") ' I used the same sheet for my test
With WsT
Ct = 4 ' specify the column to write to (here column D)
Rt = .Cells(.Rows.Count, Ct).End(xlUp).Row + 1
End With
Application.ScreenUpdating = False
With WsS
Cs = 1 ' specify the column to read from (here column A)
Rl = .Cells(.Rows.Count, Cs).End(xlUp).Row
For Rs = 2 To Rl Step 4 ' start from row 2
WsT.Cells(Rt, Ct).Value = .Cells(Rs, Cs).Value
Rt = Rt + 1
Next Rs
End With
Application.ScreenUpdating = True
End Sub
こんにちは、 '.Cells(.Rows.Count、Ct).End(xlUp).Row + 1'この行は何をしますか? – aaa
完璧に作業しました!ありがとう、Variatus! :) – user3360708
@ppz 'Cells(1).Row'は、Cells(1)の行番号を返します。あなたが尋ねる数式は、Ct '列の最後の空でないセルの行番号を返します。これは、Ct列の最初の空白行の番号になります。 – Variatus
- 1. ネストされたForループでカウンタがインクリメントしない - Excel VBA
- 2. VBA - ループ付きPB
- 3. VBA - インクリメント付きのコピーと貼り付け
- 4. Excel VBA ADOループ
- 5. Excel VBA Whileループ
- 6. VBA&Excel - ループeecordset
- 7. ピボットテーブル付きExcelのVBAコード
- 8. Excel VBA条件付きテキスト
- 9. Excel VBAループ条件付き行ごとの書式設定
- 10. Excel VBA:ループWebクエリ
- 11. ループとソルバーダイアログボックス(Excel VBA)
- 12. Excel VBA日付エラー付きデータのコピー
- 13. VBA FOR列をインクリメントするループ
- 14. 条件付きループのVBAコード
- 15. VBA EXCEL:ループ上書き結果
- 16. 行をインクリメントし、EXCEL
- 17. Excel VBA - サブフォルダのデータを含むループVBA
- 18. Excel VBAダイナミックレンジ/ループ問題
- 19. Excel VBAループ範囲とスキップブランク
- 20. Nシートのループ - Excel VBA
- 21. ループ状態のExcel VBA
- 22. 各ループ発行のVBA Excel
- 23. Excel VBAループ&各(行単位)
- 24. Excel VBAの複数のループ
- 25. Excel VBA - 変数forループ
- 26. Excel(2007)VBA - 。引用符付きの式。
- 27. Excel VBAコピー - コード付きファイル移動
- 28. 変数付きのExcel VBA数式
- 29. Excel VBA:複数の名前付き範囲のループをコピーします。
- 30. Laravelクエリービルダーアップデート(インクリメント付き)
あなたの 'For x = begin begin increment step'文で' increment'として '4'を使い、' x'を行番号として使いますか? – YowE3K