Hi all,
I'm looking for some help making a macro.
I have a bunch of files in a folder. I want a macro that opens up each file one by one, and if the names match, then copy the value, date and certificate associated with that name onto the master spreadsheet.
So in the folder, I have excel files that have the following information in each sheet in the second tab:
[table="width: 500", class: grid"]
[tr]
[td]Certificate[/td]
[td]A8[/td]
[/tr]
[tr]
[td]date[/td]
[td]Dec 9[/td]
[/tr]
[tr]
[td]name2[/td]
[td]1.3[/td]
[/tr]
[tr]
[td]name3[/td]
[td]1.5[/td]
[/tr]
[tr]
[td]name6[/td]
[td]3.0[/td]
[/tr]
[/table]
In the master sheet, I have the following columns:
[table="width: 500, class: grid"]
[tr]
[td]UNIQUENAME[/td]
[td]VALUE[/td]
[td]DATE[/td]
[td]CERTIFICATE[/td]
[/tr]
[tr]
[td]name1[/td]
[td][/td]
[td][/td]
[td][/td]
[/tr]
[tr]
[td]name2[/td]
[td][/td]
[td][/td]
[td][/td]
[/tr]
[tr]
[td]name3[/td]
[td][/td]
[td][/td]
[td][/td]
[/tr]
[/table]
I am looking for a way for excel to automatically fill in the value, date, and certificate numbers by looking them up in the sheets and pasting them into the correct row. For example, like so:
[table="width: 500, class: grid"]
[tr]
[td]UNIQUENAME[/td]
[td]VALUE[/td]
[td]DATE[/td]
[td]CERTIFICATE[/td]
[/tr]
[tr]
[td]name1[/td]
[td][/td]
[td][/td]
[td][/td]
[/tr]
[tr]
[td]name2[/td]
[td]1.3[/td]
[td]Dec 9[/td]
[td]A8[/td]
[/tr]
[tr]
[td]name3[/td]
[td]1.5[/td]
[td]Dec 9[/td]
[td]A8[/td]
[/tr]
[/table]
So far, I got the macro to open the file folder, and open the files one by one, but I don't know how to code it so it searches for matches, and copies the correct cells over.
Help is really appreciated!
Thank you. =)
I'm looking for some help making a macro.
I have a bunch of files in a folder. I want a macro that opens up each file one by one, and if the names match, then copy the value, date and certificate associated with that name onto the master spreadsheet.
So in the folder, I have excel files that have the following information in each sheet in the second tab:
[table="width: 500", class: grid"]
[tr]
[td]Certificate[/td]
[td]A8[/td]
[/tr]
[tr]
[td]date[/td]
[td]Dec 9[/td]
[/tr]
[tr]
[td]name2[/td]
[td]1.3[/td]
[/tr]
[tr]
[td]name3[/td]
[td]1.5[/td]
[/tr]
[tr]
[td]name6[/td]
[td]3.0[/td]
[/tr]
[/table]
In the master sheet, I have the following columns:
[table="width: 500, class: grid"]
[tr]
[td]UNIQUENAME[/td]
[td]VALUE[/td]
[td]DATE[/td]
[td]CERTIFICATE[/td]
[/tr]
[tr]
[td]name1[/td]
[td][/td]
[td][/td]
[td][/td]
[/tr]
[tr]
[td]name2[/td]
[td][/td]
[td][/td]
[td][/td]
[/tr]
[tr]
[td]name3[/td]
[td][/td]
[td][/td]
[td][/td]
[/tr]
[/table]
I am looking for a way for excel to automatically fill in the value, date, and certificate numbers by looking them up in the sheets and pasting them into the correct row. For example, like so:
[table="width: 500, class: grid"]
[tr]
[td]UNIQUENAME[/td]
[td]VALUE[/td]
[td]DATE[/td]
[td]CERTIFICATE[/td]
[/tr]
[tr]
[td]name1[/td]
[td][/td]
[td][/td]
[td][/td]
[/tr]
[tr]
[td]name2[/td]
[td]1.3[/td]
[td]Dec 9[/td]
[td]A8[/td]
[/tr]
[tr]
[td]name3[/td]
[td]1.5[/td]
[td]Dec 9[/td]
[td]A8[/td]
[/tr]
[/table]
So far, I got the macro to open the file folder, and open the files one by one, but I don't know how to code it so it searches for matches, and copies the correct cells over.
Code:
Sub CompleteMasterSpreadsheet()
'DECLARE AND SET VARIABLES
Dim wbk As Workbook
Dim FileName As String
Dim Path As String
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
Path = .SelectedItems(1) & "\"
End With
FileName = Dir(Path & "*.xls*")
'Loop to open excel files
Do While Len(FileName) > 0 'IF NEXT FILE EXISTS THEN
Set wbk = Workbooks.Open(Path & FileName)
'
' CODE to search for matches, copy them if there is a match
'
' end of code
wbk.Close True
FileName = Dir
Loop
End Sub
Help is really appreciated!
Thank you. =)