Skip to main content

Conas comhaid shonracha a bhogadh ó fhillteán amháin go fillteán eile in Excel?

Ag ceapadh, tá fillteán mór agam ina bhfuil cineálacha comhaid, mar shampla docx, jpg, xlsx, srl mar a thaispeántar ar an scáileán a leanas. Anois, ba mhaith liom roinnt cineálacha comhaid ar leith a bhogadh ón bhfillteán go fillteán nua eile gan ceann ar cheann a bhogadh de láimh. An bhfuil aon smaointe maithe agat chun an tasc seo a réiteach in Excel?

Bog comhaid shonracha ó fhillteán amháin go fillteán eile le cód VBA


Bog comhaid shonracha ó fhillteán amháin go fillteán eile le cód VBA

Chun na cineálacha sonracha comhaid go léir a bhogadh ó fhillteán amháin go fillteán eile chomh tapa agus is mian leat, d’fhéadfadh an cód VBA seo a leanas cabhrú leat, déan mar seo le do thoil:

1. Coinnigh síos ALT + F11 eochracha a oscailt Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Cliceáil Ionsáigh > Modúil, agus greamaigh an cód seo a leanas sa Modúil Fuinneog.

Cód VBA: Bog cineálacha sonracha comhaid ó fhillteán amháin go ceann eile:

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

nótaí: Sa chód thuas, "* .xlsx *""* .jpg"sa script: xExtArr = Eagar ("*. xlsx *", "* .jpg") an iad na cineálacha comhaid is mian leat a bhogadh, is féidir leat iad a athrú go daoine eile nó cineálacha comhaid eile a chur leis de réir mar is gá duit.

3. Ansin brúigh F5 eochair chun an cód seo a rith, agus fuinneog popped amach chun a mheabhrú duit an fillteán bunaidh a roghnú inar mian leat na comhaid a bhogadh, féach ar an scáileán:

4. Ansin cliceáil OK, agus fuinneog eile aníos, roghnaigh an fillteán ceann scríbe inar mian leat na comhaid a bhogadh, féach ar an scáileán:

5. Agus ansin cliceáil OK, popfaidh bosca pras amach le cur i gcuimhne duit cé mhéad comhad a aistríodh, dún é, agus is féidir leat a fheiceáil na comhaid shonracha jpg, xlsx a aistríodh isteach san fhillteán sonraithe, féach an scáileán:

Uirlisí Táirgiúlachta Oifige is Fearr

🤖 Kutools AI Aide: anailís sonraí a réabhlóidiú bunaithe ar: Forghníomhú Chliste   |  Gin Cód  |  Cruthaigh Foirmlí Saincheaptha  |  Anailís a dhéanamh ar Sonraí agus Cairteacha a Ghin  |  Feidhmeanna Kutools a agairt...
Gnéithe Coitianta: Faigh, Aibhsigh nó Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha le Focail, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Supercharge Do Scileanna Excel le Kutools le haghaidh Excel, agus Éifeachtúlacht Taithí Cosúil Ná Roimhe. Kutools le haghaidh Excel Tairiscintí Níos mó ná 300 Ardghnéithe chun Táirgiúlacht a Treisiú agus Sábháil Am.  Cliceáil anseo chun an ghné is mó a theastaíonn uait a fháil ...

Tuairisc


Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
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