- Excel VBA 質問スレ Part38 [転載禁止]©2ch.net
977 :デフォルトの名無しさん[sage]:2015/11/27(金) 16:58:24.01 ID:ueGoHWsY - sheet2のA5〜A3800まで1000〜9999までの数字が重複なくランダムにあり、
sheet1のA2〜A5500まで1000〜9999までの数字が重複なくランダムにある状態で、 sheet1とsheet2のAセルの値が一致した場合、一致した行のsheet2のD〜Gセルの値を一致した行のsheet1のD〜Gセルに 入れたいのですが、下記の2重ループだと時間がかかってしまいます。 もっと時間を短縮したいのですが、何か方法はないでしょうか? Sub test() Application.ScreenUpdating = False With Worksheets("sheet1") For rw = 2 To 5500 For cnt = 5 To 3800 If .Cells(rw, 1).Value = Cells(cnt, 1).Value Then .Cells(rw, 4).Value = Cells(cnt, 4).Value .Cells(rw, 5).Value = Cells(cnt, 5).Value .Cells(rw, 6).Value = Cells(cnt, 6).Value .Cells(rw, 7).Value = Cells(cnt, 7).Value Exit For End If Next Next End With Application.ScreenUpdating = True End Sub
|