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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

RickXL

MrExcel MVP
Joined
Sep 9, 2013
Messages
4,328
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,195,582
Messages
6,010,577
Members
441,557
Latest member
Jbest23

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
Top