Sub Click()
Dim vFile As Variant
Dim wbCopyTo As Workbook
Dim wsCopyTo As Worksheet
Dim wbCopyFrom As Workbook
Dim wsCopyFrom As Worksheet
Set wbCopyTo = ActiveWorkbook
Set wsCopyTo = ActiveSheet
'-------------------------------------------------------------
'Open file with data to be copied
vFile = Application.GetOpenFilename("Excel Files (*.xlsx*)," & _"*.xlsx*", 1, "Select Excel File", "Open", False)
'If Cancel then Exit
If TypeName(vFile) = "Boolean" Then
Exit Sub
Else
Set wbCopyFrom = Workbooks.Open(vFile)
Set wsCopyFrom = wbCopyFrom.Worksheets("Corrosion")
End If
'--------------------------------------------------------------
'comparing data and copy range
Dim n, i, j, k, l, o, w, s As Double
n = wbCopyFrom.Worksheets("Corrosion").Cells(12, 3).Value
s = wbCopyFrom.Worksheets("Corrosion").Cells(22 + k, 3).Value
w = wbCopyTo.ActiveSheet("Investigation Summary").Cells(8045 + j, 5).Value
If (w = s) Then
o = 8 + j
dbln = "Y" & o
dblq = "BB" & o
dblt = "BK" & o
dblu = "BM" & o
wsCopyFrom.Range(dblm, dblp).Copy
wsCopyTo.Range(dbln, dblq).PasteSpecial Paste:=xlPasteValues
i = i + 1
k = k + 1
l = l + 1
o = 8 + j
End If
'----------------------------------------
j = j + 1
Loop
wbCopyFrom.Close SaveChanges:=False
End Sub