|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test1()
- Dim sPath As String
- With Application.FileDialog(msoFileDialogFolderPicker)
- .InitialFileName = ThisWorkbook.Path
- If .Show Then sPath = .SelectedItems(1) Else Exit Sub
- End With
- If Right(sPath, 1) <> "\" Then sPath = sPath & "\"
- Dim ar, i As Long, sExt As String, sGrade As String, sSrc As String, sDst As String
- sExt = ".jpg"
- sGrade = Val(Split(ThisWorkbook.Name, "(")(1)) & "班"
- ar = Range("A1").CurrentRegion
- For i = 2 To UBound(ar)
- sSrc = sPath & ar(i, 1) & sExt
- sDst = sPath & sGrade & Val(Right(ar(i, 2), 3)) & "号" & ar(i, 1) & sExt
- If Len(Dir(sSrc)) Then
- If Len(Dir(sDst)) Then Kill sDst
- Name sSrc As sDst
- End If
- Next
- Beep
- End Sub
复制代码 |
|