Can someone help me with the following:
I have an issue with "Set ch1 =
"
The file name (or rather the last few characters of its name change slightly everyday), thus I need to add wildcard (*) or something similar.
How do I do "Set ch1 =" with a file, which name changes?
Here is part of the code I have developed.
Option Explicit
Sub Open_Latest_Cheque()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Call Open_Latest_File
Dim ch1 As Workbook, AC As Workbook, temp As Workbook
Dim ch1ws As Worksheet, ACws As Worksheet
Dim ACwsLR As Long, tempName As String
**Set ch1 = Workbooks("Sum100123.csv")**
Set ch1ws = ch1.Sheets(1)
Set AC = Workbooks("Mon.xlsm")
Set ACws = AC.Sheets("Data")
Dim MyPath As String, MyFile As String, LatestFile As String
Dim LatestDate As Date, LMD As Date.............
Thanks
Try this:
Sub test_partial_name()
Dim pt_nm As Workbook
For Each pt_nm In Application.Workbooks
If (pt_nm.Name) Like "Sum1#123.csv" Then
Exit For
End If
Next pt_nm
If Not pt_nm Is Nothing Then
pt_nm.Activate
Else
MsgBox "The file has not opened!"
End If
With Sheets(1)
Cells(1, 1).Value = "its working? Yes"
End With
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With