[VBA実践]RangeとCellsを組み合わせよう![#3]
前回の記事はこちら前回の記事で、・抽出担当者のデータのみを抜き出して転記するという、マクロのメイン機能は作成完了しました。ただ、まだまだ改良の余地はあります。今回の記事を通して、RangeとCellsを組み合わせ、前回書いた記事をもう少しスマートにしてみましょう。前回書いた記事は以下の通りですね。Sub 担当者ごと抽出()
Dim targetName As String
Dim rowLong As Long
Dim exRowLong As Long
targetName = Cells(1, 9).Value
exRowLong = 2
For rowLong = 2 To 16
If Cells(rowLong, 6).Value = targetName Then
'一緒だった時の処理
Debug.Print "担当者名が" & targetName & "と同じです!"
Cells(exRowLong, 11).Value = Cells(rowLong, 1).Value
Cells(exRowLong, 12).Value = Cells(rowLong, 2).Value
Cells(exRowLong, 13).Value = Cells(rowLong, 3).Value
Cells(exRowLong, 14).Value = Cel
0