こんにちわ
ちょっと以下を試してみて下さい。
Sub Test_1() ' まっさらな行に実行 With Range("A3:B3") .UnMerge .Clear .Cells(1).Value = String(47, "a") .HorizontalAlignment = xlCenterAcrossSelection .VerticalAlignment = xlTop .WrapText = True .Merge .HorizontalAlignment = xlLeft End With End Sub
Sub Test_2() ' 確実に実行 Dim MyA As Variant With Range("A3:B3") ' C列 以降同行の情報 MyA = .EntireRow.Cells(3).Resize(, Columns.Count - 2).Formula ' ↓ 何処かまっさらな行をコピー .Worksheet.Rows(10000).Copy .EntireRow .Cells(1).Value = String(47, "a") .HorizontalAlignment = xlCenterAcrossSelection .VerticalAlignment = xlTop .WrapText = True .Merge .HorizontalAlignment = xlLeft .EntireRow.Cells(3).Resize(, Columns.Count - 2).Formula = MyA End With Erase MyA End Sub
この記事にはVBAのコードが含まれています。
緑の太文字→注釈 茶色の太文字→条件分岐 赤の太文字→ループ 青の太文字→その他
|