Hello =)
I need help making a macro. I have a bunch of files in a folder, and I am trying to organize them. In sheet(2) column B in those files, there is a name. Basically if the name starts with MC / mc / Mc, I want the macro to copy over that name to a master, as well as its value from column sheet(2) column G, a date from wbk.Sheets(1).Range("C7"), a certificate number from wbk.Sheets(1).Range("F7"), and a link to the file.
Below is what I have been messing with, however I'm not very good at VBA. I appreciate any help.
Thank you very much!</looks></looks>
I need help making a macro. I have a bunch of files in a folder, and I am trying to organize them. In sheet(2) column B in those files, there is a name. Basically if the name starts with MC / mc / Mc, I want the macro to copy over that name to a master, as well as its value from column sheet(2) column G, a date from wbk.Sheets(1).Range("C7"), a certificate number from wbk.Sheets(1).Range("F7"), and a link to the file.
Below is what I have been messing with, however I'm not very good at VBA. I appreciate any help.
Code:
Sub CopyMCsOverToMaster()
'DECLARE AND SET VARIABLES
Dim wbk As Workbook
Dim Sht As Worksheet
Dim FileName As String
Dim Path As String
Dim Cl As Range
Dim Rng As Range
Dim Cnt As Long
Application.ScreenUpdating = False
With Application.FileDialog(4)
.Show
Path = .SelectedItems(1) & "\"
End With
FileName = Dir(Path & "*.xls*")
Do While Len(FileName) > 0
Set wbk = Workbooks.Open(Path & FileName)
'unhide all worksheets
For Each WS In ActiveWorkbook.Worksheets
WS.Visible = xlSheetVisible
Next WS
Cnt = Cnt + 1
Set Sht = wbk.Sheets(4) 'Looks for assays in sheet 4
If wbk.Sheets(4).Range("B2").Value Like "*MC*" Then ' If value is MC
.Item(Rng.Value).Offset(, 0).Value = wbk.Sheets(4).Range(, 0).Value ' adds the MC name to column A
.Item(Rng.Value).Offset(, 5).Value = Rng.Offset(, 5).Value 'adds the value to the master
.Item(Rng.Value).Offset(, 10).Value = wbk.Sheets(1).Range("C7").Value ' adds the date to the master
.Item(Rng.Value).Offset(, 11).Value = wbk.Sheets(1).Range("F7").Value 'add the certificate to the master
WS.Range.Offset(a, 2).Value = c.Address
WS.Hyperlinks.Add Anchor:=WS.Range("D4").Offset(a, 0), Address:=myfolder & Value, SubAddress:= _
Sht.Name & "!" & c.Address, TextToDisplay:="Link"
End If
Next Rng
wbk.Close False
FileName = Dir
Loop
End With
MsgBox Cnt
End Sub
<looks for="" assays="" in="" sheet="" 4
<looks for="" assays="" in="" sheet="" 4
Thank you very much!</looks></looks>
Last edited: