Abrir libro excel usando comodines

juanpy

New Member
Joined
Aug 21, 2014
Messages
17
Estimados,

La idea es abrir un libro excel desde una ubicacion pre definida, cuyo nombre esta estructurado de la siguiente manera.

LibroBanco201409051345.xlsx
|ParteFija|-Fecha--|Hora

La parte "LibroBanco" es fija, no asi la fecha y hora que son variables

Existen varios archivos en el directorio con este nombre, el que yo necesito abrir, siempre sera el ultimo generado.

Estube probando con ?? o **, pero no sirve (LibroBanco????????????.xlsx).

¿Alguien sabe como lo puedo hacer?

Muchas gracias.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi,

Sorry, no hablo Espagnol.

Try this:
Code:
Sub xx()
    Dim FileTemp As String, FileName As String
    FileTemp = Dir("C:\Users\RickXL\Documents\@Excel\MasterFolder\LibroBanco*.xlsx")     '  <=== Your Folder
    Do While FileTemp <> ""
        FileName = FileTemp
        FileTemp = Dir
    Loop
    Debug.Print FileName   '  <=== Answer
End Sub

The value of FileName will be the most recent file.

Regards,
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top