I want to use if-then statement across two workbooks.
I've defined x as Long but x does not appear to hold the value of the sum of all cells in column B
But the code looks right, any thoughts?
Sub mycode()
Dim x As Long
myRange = Workbooks("Book2").Sheets("Sheet1").Range("B1", _
Range("B1").End(xlDown))
x = WorksheetFunction.Sum(myRange) '<<does not seem to hold value
If Workbooks("Book1").Sheets("Sheet1").Range("A1").Value = x Then
MsgBox ("values equal")
Else
MsgBox ("please review values")
End If
End Sub
Aucun commentaire:
Enregistrer un commentaire