How To Get Cell Value By Row And Column In Excel VBA - ExcelDemy

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

Get Cell Value by Row and Column.xlsm

Related Articles

  • How to Get Cell Value as String Using Excel VBA
  • Excel VBA Set Cell Value in Another Worksheet
Get FREE Advanced Excel Exercises with Solutions!

Từ khóa » Visual Basic Excel Get Cell Value