|
参与一下。。。
- Sub ykcbf() '//2024.3.28
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- p = ThisWorkbook.Path
- Set sh = ThisWorkbook.Sheets("名单")
- arr = sh.UsedRange
- b = [{"姓名","身份证","电话号码","城市","区域","课程","级别"}]
- For j = 1 To UBound(arr, 2)
- s = arr(2, j)
- If s = "姓名" Then s = "申请人"
- d(s) = j
- Next
- c = UBound(arr, 2)
- With Application.FileDialog(msoFileDialogFilePicker)
- .InitialFileName = p
- .Title = "请选择对应Excel文件"
- .AllowMultiSelect = False
- .Filters.Clear
- .Filters.Add "Excel文件", "*.xls*"
- If .Show Then f = .SelectedItems(1) Else Exit Sub
- End With
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets("Sheet1")
- arr = .UsedRange
- wb.Close False
- End With
- ReDim brr(1 To UBound(arr), 1 To c)
- For i = 2 To UBound(arr)
- If arr(i, 3) <> Empty Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- s = arr(1, j)
- If d.exists(s) Then
- brr(m, d(s)) = arr(i, j)
- End If
- Next
- End If
- Next
- With sh
- .UsedRange.Offset(2).ClearContents
- .Columns(2).NumberFormatLocal = "@"
- With .[a3].Resize(m, c)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter '//列居中
- .VerticalAlignment = xlCenter
- End With
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|