jaeremata
New Member
- Joined
- Jan 20, 2021
- Messages
- 24
- Office Version
- 2019
- 2016
- Platform
- Windows
Hi, Good day. I have a concern I hope anyone can help me. I have a list of files from d2:d4 on a worksheet. I need a macro that can open one at a time copy the latest date on a specific column and sheet tab and paste it to another worksheets, then close it, then open the next, etc.
On Column D it show a link or list of file for each vendor score, I want the macro to open the file, go to sheet tab "quality" then on column J, it will look for the latest date but it on text format. Once it finds the latest date, it will copy the date and paste on another sheets name result, and then close and open the next.
I found some code, but was not able to tweak it.
On Column D it show a link or list of file for each vendor score, I want the macro to open the file, go to sheet tab "quality" then on column J, it will look for the latest date but it on text format. Once it finds the latest date, it will copy the date and paste on another sheets name result, and then close and open the next.
I found some code, but was not able to tweak it.
VBA Code:
Sub test()
Dim myDir As String, r As Range, fn As String, msg As String
myDir = "c:\test\"
For Each r In Range("c2", Range("c" & Rows.Count).End(xlUp))
fn = Dir(myDir & r.Value)
If fn = "" Then
msg = msg & vbLf & r.Value
Else
With Workbooks.Open(myDir & fn)
.Sheets("YourSheetName").Range("MKTG").Copy _
ThisWorkbook.Sheets("SomeSheet").Range("SomeRange")
.Close False
End With
End If
Next
If Len(msg) Then
MsgBox "Not found" & msg
End If
End Sub