Forum Discussion
QCube680
Jun 19, 2022Copper Contributor
Excel macro - Find different filenames
Hi there, So I'm trying to create a tool used for work purposes, every time we download a file from our server, it is labelled as "USCOTRN" - however, when multiple of these files are downloaded,...
Subodh_Tiwari_sktneer
Jun 20, 2022Silver Contributor
You may try something like this...
Sub USCOTRNCopy()
Dim wbDest As Workbook
Dim wbSource As Workbook
Dim wb As Workbook
Dim wsSource As Worksheet
Set wbDest = ThisWorkbook
For Each wb In Workbooks
If wb.Name Like "USCOTRN*.csv" Then
Set wbSource = wb
Exit For
End If
Next wb
If Not wb Is Nothing Then
Set wsSource = wbSource.Worksheets("USCOTRN")
wsSource.Move after:=wbDest.Worksheets(1)
End If
End Sub