帮忙改下程序?
Sub Macro1()Dim wb As Workbook, c As Range, r As Range, rng As Range, lr As Long
Application.ScreenUpdating = False
Set rng = Range("F4:I4,N4:O4,Q4:R4,W4:X4")
Set wb = GetObject(ThisWorkbook.Path & "\Book.xls")
With wb.Sheets(1)
lr = .[a65536].End(xlUp).Row - 2
With .Rows(2)
For Each r In rng
Set c = .Find(r.Value, , , 1)
If Not c Is Nothing Then
c.Offset(1).Resize(lr).Copy r.Offset(1)
End If
Next
End With
End With
wb.Close False
Application.ScreenUpdating = True
End Sub
Sub Macro2()
Dim wb As Workbook, sh As Worksheet, c As Range, r As Range, rng As Range, lr As Long
Application.ScreenUpdating = False
Set sh = ActiveSheet
Set rng = Range("F4:I4,N4:O4,Q4:R4,W4:X4")
Set wb = GetObject(ThisWorkbook.Path & "\Book.xls")
With wb.Sheets(1)
lr = .[a65536].End(xlUp).Row - 2
With .Rows(2)
For Each r In rng
Set c = .Find(r.Value, , , 1)
If Not c Is Nothing Then
c.Offset(1).Resize(lr).Copy sh.Cells(65536, r.Column).End(xlUp).Offset(1)
End If
Next
End With
End With
wb.Close False
Application.ScreenUpdating = True
End Sub
Sub Macro3()
Dim wb As Workbook, sh As Worksheet, c As Range, r As Range, rng As Range, lr As Long, m&
Application.ScreenUpdating = False
Set sh = ActiveSheet
Set rng = Range("F4:I4,N4:O4,Q4:R4,W4:X4")
Set wb = GetObject(ThisWorkbook.Path & "\Book.xls")
With wb.Sheets(1)
lr = .[a65536].End(xlUp).Row - 2
With .Rows(2)
For Each r In rng
Set c = .Find(r.Value, , , 1)
If Not c Is Nothing Then
m = sh.Cells(65536, r.Column).End(xlUp).Row + 1
If m > 5 Then m = m + 2
c.Offset(1).Resize(lr).Copy sh.Cells(m, r.Column)
End If
Next
End With
End With
wb.Close False
Application.ScreenUpdating = True
End Sub
[此贴子已经被作者于2016-3-25 15:22编辑过]