Hello aaaaa34,
Here are the macros I have added to the workbook "First ver 1.xlsm". There is a second worksheet "Sheet1" that has 2 buttons. One button for each macro.
Sub Macro1()
Dim c As Long
Dim Cell As Range
Dim DstWkb As Workbook
Dim DstWks As Worksheet
Dim LastRow As Long
Dim r As Long
Dim SrcWkb As Workbook
Dim SrcWks As Worksheet
Dim WkbName As String
WkbName = "Second.xlsx"
Set SrcWkb = ThisWorkbook
Set SrcWks = SrcWkb.Worksheets("Result")
On Error Resume Next
Set DstWkb = Workbooks(WkbName)
If Err = 9 Then
MsgBox "The workbook '" & WkbName & "' is Not Open.", vbCritical
Exit Sub
End If
Set DstWks = DstWkb.Worksheets("Compare")
ReDim Data(1 To 1, 1 To 10)
For Each Cell In SrcWks.Range("AL2:AS2")
c = c + 1
Data(1, c) = Cell.Value
Next Cell
For Each Cell In SrcWks.Range("AL6:AM6")
c = c + 1
Data(1, c) = Cell.Value
Next Cell
r = 10
LastRow = DstWks.Cells(Rows.Count, "L").End(xlUp).Row
If LastRow < r Then LastRow = r Else LastRow = LastRow + 1
DstWks.Cells(LastRow, "L").Resize(1, c).Value = Data()
On Error GoTo 0
End Sub
Sub Macro2()
Dim DstWkb As Workbook
Dim DstWks As Worksheet
Dim DstRng As Range
Dim SrcRng As Range
Dim SrcWkb As Workbook
Dim SrcWks As Worksheet
Dim WkbName As String
WkbName = "Third.xlsx"
Set SrcWkb = ThisWorkbook
Set SrcWks = SrcWkb.Worksheets("Result")
Set SrcRng = SrcWks.Range("Y2:AH2")
On Error Resume Next
Set DstWkb = Workbooks(WkbName)
If Err = 9 Then
MsgBox "The workbook '" & WkbName & "' is Not Open.", vbCritical
Exit Sub
End If
Set DstWks = DstWkb.Worksheets("Ready")
Set DstRng = DstWks.Range("B2:K2")
DstRng.Value = Empty
DstRng.Value = SrcRng.Value
On Error GoTo 0
End Sub
Bookmarks