How to Get Cell Value by Row and Column in Excel VBA

Get Cell Value by Row and Column in Excel VBA (Quick View)

Sub Cell_Value_from_Whole_Worksheet()

Value = Worksheets("Sheet1").Cells(7, 3)

MsgBox Value

End Sub

VBA Code to Get Cell Value by Row and Column in Excel Worksheet


How to Get Cell Value by Row and Column in Excel VBA: 3 Methods


Method 1 – Get Cell Value by Row and Column from the Whole Worksheet in Excel VBA

To get the value from the cell in the 4th row and the 6th column of the worksheet called Sheet1, you can use:

Value = Worksheets("Sheet1").Cells(4, 6)

⧭ Example:

We’ve got a worksheet called Sheet1 with the names of some students and their marks in Physics, Chemistry, and Mathematics of a School. The data set starts right from cell A1 of the worksheet.

Data Set to Get Cell Value by Row and Column in Excel VBA

To get the marks of the 6th student in Chemistry, you have to get the cell value from the 7th row and 3rd column of the worksheet.

⧭ VBA Code:

Sub Cell_Value_from_Whole_Worksheet()

Value = Worksheets("Sheet1").Cells(7, 3)

MsgBox Value

End Sub

VBA Code to Get Cell Value by Row and Column in Excel Worksheet

⧭ Output:

Run the code. It’ll display the cell value from the 7th row and 3rd column of Sheet1, which is 78.

Read More: Excel VBA: Get Cell Value from Another Workbook without Opening


Method 2 – Get Cell Value by Row and Column from the Used Range in Excel VBA

To get the value from the cell in the 4th row and the 6th column of the used range of the worksheet called Sheet2, you can use:

Value = Worksheets("Sheet2").UsedRange.Cells(4, 6)

⧭ Example:

We’ve got another worksheet called Sheet2 with the same data set, the names of some students and their marks in Physics, Chemistry, and Mathematics of a School. This time the data set starts from cell B2 of the worksheet.

Data Set to Get Cell Value by Row and Column in Excel VBA

To get the marks of the 6th student in Chemistry again, you have to get the value from the 7th row and the 3rd column of the used range.

⧭ VBA Code:

Sub Cell_Value_from_Used_Ranget()
Value = Worksheets("Sheet1").UsedRange.Cells(7, 3)
MsgBox Value
End Sub

VBA Code to Get Cell Value by Row and Column in Excel VBA

⧭ Output:

Run the code. It’ll display the cell value from the 7th row and 3rd column of the used range of Sheet2, which is 78.


Method 3 – Get the Cell Value by Row and Column from a Specific Range in Excel VBA

To get the value from the cell in the 4th row and the 6th column of the range E2:H14of the worksheet called Sheet3, you can use:

Value = Worksheets("Sheet3").Range("E2:H14").Cells(4, 6)

⧭ Example:

We’ve got another worksheet called Sheet3 with two data sets. One with the names and IDs of the students (B2:C14)  of a School, and the other with the names of some students and their marks in Physics, Chemistry, and Mathematics (E2:H14).

Data Set to Get Cell Value by Row and Column in Excel VBA

To get the marks of the 6th student in Chemistry again, you have to get the value from the 7th row and the 3rd column of the range E2:H14 of the worksheet.

⧭ VBA Code:

Sub Cell_Value_from_Selected_Range()

Value = Worksheets("Sheet3").Range("E2:H14").Cells(7, 3)

MsgBox Value

End Sub

VBA Code to Get Cell Value by Row and Column in Excel VBA

⧭ Output:

Run the code. It’ll display the cell value from the 7th row and 3rd column of the range E3:G13 of Sheet3, which is 78.


Download the Practice Workbook


Related Articles

Get FREE Advanced Excel Exercises with Solutions!
Rifat Hassan
Rifat Hassan

Rifat Hassan, BSc, Electrical and Electronic Engineering, Bangladesh University of Engineering and Technology, has worked with the ExcelDemy project for almost 2 years. Within these 2 years, he has written over 250 articles. He has also conducted a few Boot Camp sessions on effective coding, especially Visual Basic for Applications (VBA). Currently, he is working as a Software Developer to develop and deploy additional add-ins to enhance the customers with a more sophisticated experience with Microsoft Office Suits,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo