You can use the following methods in VBA to get the cell value in another sheet:
Method 1: Get Cell Value from Another Sheet
Sub GetCellAnotherSheet()
ActiveCell.Value = Worksheets("Sheet2").Range("A2")
End Sub
This particular macro will get the value of cell A2 in Sheet2 to and return it in the currently active cell.
Method 2: Get Result of Operation of Cell Values from Another Sheet
You can also perform some operation on cells in another sheet and return the result of the operation in the currently active cell.
For example, you can use the following syntax to sum the values in the range B2:B10 in Sheet2 and return the sum in the currently active cell:
Sub GetCellAnotherSheet()
ActiveCell.Value = WorksheetFunction.Sum(Worksheets("Sheet2").Range("B2:B10"))
End Sub
The following examples show how to use each method in practice.
Example 1: Get Cell Value from Another Sheet
Suppose we have the following sheet called Sheet2 that contains information about various basketball players:
Suppose we currently have cell A2 in Sheet1 selected as our active cell.
We can create the following macro to get the value in cell A2 of Sheet2 and return it in the currently active cell:
Sub GetCellAnotherSheet()
ActiveCell.Value = Worksheets("Sheet2").Range("A2")
End Sub
When we run this macro, we can see that the value in cell A2 of Sheet1 is now set to “Mavs”, which matches the value from cell A2 of Sheet2:
Example 2: Get Result of Operation of Cell Values from Another Sheet
Once again suppose we have the following sheet called Sheet2 that contains information about various basketball players:
We can use the following macro to sum the values in the points column of Sheet2 and return the result in the currently active cell, which happens to be cell A2 in Sheet1:
Sub GetCellAnotherSheet()
ActiveCell.Value = WorksheetFunction.Sum(Worksheets("Sheet2").Range("A2"))
End Sub
When we run this macro, we can see that the sum of values in the range A2:A10 of Sheet2 is now shown in cell A2 of Sheet1:
Additional Resources
The following tutorials explain how to perform other common tasks in VBA:
VBA: How to Set Cell Value in Another Sheet
VBA: How to Select Range from Active Cell
VBA: How to Delete Rows Based on Cell Value