|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 yaozong 于 2013-1-15 13:15 编辑
lee1892 发表于 2013-1-15 12:01
楼上弄反了吧,源是列连续,目标是不连续的,呵呵~
方向反过来的话(用循环复制)
Private Sub CommandButton1_Click()
Dim Wb As Workbook
Dim Temp As String
Dim r&, j%
Application.ScreenUpdating = False
Temp = ThisWorkbook.Path & "\需导入相应字段的数据文件.xls"
Set Wb = GetObject(Temp)
With Wb.Sheets("sheet1")
r = .[a65536].End(3).Row
For j = 1 To 5
Set cel = Range("a1:j1").Find(.Cells(1, j), , , 1)
If Not cel Is Nothing Then
.Cells(2, j).Resize(r - 1).Copy Cells(2, cel.Column)
End If
Next
End With
Wb.Close False
Set Wb = Nothing
Application.ScreenUpdating = True
End Sub |
评分
-
1
查看全部评分
-
|