Skip i'r prif gynnwys

Sut i symud ffeiliau penodol o un ffolder i'r llall yn Excel?

Gan dybio, mae gen i ffolder fawr sy'n cynnwys mathau o ffeiliau, fel docx, jpg, xlsx, ac ati fel y dangosir y screenshot canlynol. Nawr, rwyf am symud rhai mathau penodol o ffeiliau o'r ffolder i ffolder newydd arall heb symud fesul un â llaw. Oes gennych chi unrhyw syniadau da i ddatrys y dasg hon yn Excel?

Symud ffeiliau penodol o un ffolder i ffolder arall gyda chod VBA


Symud ffeiliau penodol o un ffolder i ffolder arall gyda chod VBA

I symud yr holl fathau penodol o ffeiliau o un ffolder i'r llall mor gyflym ag y dymunwch, gall y cod VBA canlynol eich helpu, gwnewch fel hyn:

1. Dal i lawr ALT + F11 allweddi i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Cliciwch Mewnosod > Modiwlau, a gludwch y cod canlynol yn y Modiwlau Ffenestr.

Cod VBA: Symudwch fathau penodol o ffeiliau o un ffolder i un arall:

Sub MoveFiles()
'Updateby Extendoffice
    Dim xFd As FileDialog
    Dim xTFile As String
    Dim xExtArr As Variant
    Dim xExt As Variant
    Dim xSPath As String
    Dim xDPath As String
    Dim xSFile As String
    Dim xCount As Long
    Set xFd = Application.FileDialog(msoFileDialogFolderPicker)
    xFd.Title = "Please select the original folder:"
    If xFd.Show = -1 Then
        xSPath = xFd.SelectedItems(1)
    Else
        Exit Sub
    End If
    If Right(xSPath, 1) <> "\" Then xSPath = xSPath + "\"
    xFd.Title = "Please select the destination folder:"
    If xFd.Show = -1 Then
        xDPath = xFd.SelectedItems(1)
    Else
        Exit Sub
    End If
    If Right(xDPath, 1) <> "\" Then xDPath = xDPath + "\"
    xExtArr = Array("*.xlsx*", "*.jpg")
    For Each xExt In xExtArr
        xTFile = Dir(xSPath & xExt)
        Do While xTFile <> ""
            xSFile = xSPath & xTFile
            FileCopy xSFile, xDPath & xTFile
            Kill xSFile
            xTFile = Dir
            xCount = xCount + 1
        Loop
    Next
    MsgBox "Total number of moved files is: " & xCount, vbInformation, "Kutools for Excel"
End Sub

Nodyn: Yn y cod uchod, "* .xlsx *""* .jpg"yn y sgript: xExtArr = Array ("*. xlsx *", "* .jpg") yw'r mathau o ffeiliau rydych chi am eu symud, gallwch eu newid i eraill neu ychwanegu mathau eraill o ffeiliau yn ôl yr angen.

3. Yna pwyswch F5 allwedd i redeg y cod hwn, a ffenestr wedi'i popio allan i'ch atgoffa i ddewis y ffolder wreiddiol lle rydych chi am symud y ffeiliau, gweler y screenshot:

4. Yna cliciwch OK, ac mae ffenestr arall wedi'i popio i fyny, dewiswch y ffolder cyrchfan lle rydych chi am symud y ffeiliau i, gweler y screenshot:

5. Ac yna cliciwch OK, bydd blwch prydlon yn popio allan i'ch atgoffa faint o ffeiliau sydd wedi'u symud, ei gau, a gallwch weld y ffeiliau jpg penodol, xlsx sydd wedi'u symud i'r ffolder penodedig, gweler y screenshot:

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
i get no popups after theselection screen
This comment was minimized by the moderator on the site
Hi,
Code works great for what I am doing. Thank you! How do you have it check if files exist in the destination folder and prompt the user to ask if they want to overwrite the files or save as another file name? I am working with .pdf files saving to the destination folder.
This comment was minimized by the moderator on the site
To move or copy files from a folder to another based on excel list, and destination (path)
on excel list. plz help...
This comment was minimized by the moderator on the site
Hello
To move or copy files from a folder to another based on excel list, the following article may help you!
This comment was minimized by the moderator on the site
Hi,
I need a help. Can we select few files and move them in to a separate folder by list in excel file?
thanks in advance
This comment was minimized by the moderator on the site
thanks a lot for your big help
This comment was minimized by the moderator on the site
Hello, Kumar,
To move or copy files from a folder to another based on excel list, the following article may help you!
https://www.extendoffice.com/documents/excel/4775-move-files-based-on-excel-list.html

Hope it can help you, thank you!
This comment was minimized by the moderator on the site
Can we select destinaton path in excel list on this macro. plz help.
This comment was minimized by the moderator on the site
Thank you very much, this is excellent. Really appreciate your help.
This comment was minimized by the moderator on the site
Hi

Thanks for helpful tip. I have around 5000 files listed on one excel file. I need to search all these files from the entire computer , if file names are matched then copy and paste in another folder
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations