I have a macro, I would like to replace the code that opens with diagbox to the one that opens automatically if there is a file with a date from this month in the folder. But here
i got error like : "Object raiable or With block wariable not set '91' " How i can change below
Below is code which i would like adapt
Here what i had and still have
Rich (BB code):
data_wb.Sheets("Year2021").Rows("1:1").Select
Below is code which i would like adapt
Rich (BB code):
ThisMonth = Format(Date, "mmmm")
MyFolder = "C:\Users\V1410190\Documents\FOLDER" & ThisMonth & ""
MyFile = Dir(MyFolder & "\CopyFinakl*.xlsm")
Do Until MyFile = ""
MyFile = Dir
Set data_wb = Workbooks.Open(MyFile, UpdateLinks:=0)
Loop
'paste copy like value and change to date format'
data_wb.Sheets("Year2021").Rows("1:1").Select
Here what i had and still have
Rich (BB code):
file_name = selectFilePK
If file_name = "" Then Exit Sub
'Set data file
Set data_wb = Workbooks.Open(file_name, UpdateLinks:=0)
Private Function selectFilePK()
Dim fd As Office.FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.InitialFileName = ActiveWorkbook.Path
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Excel", "*.xlsm"
If .Show = True Then selectFilePK = .SelectedItems(1)
Application.ScreenUpdating = False
Application.AskToUpdateLinks = False