How to Use Cell Value as Worksheet Name in Formula Reference in Excel

Here, we have 3 worksheets—January, February, and March—containing the sales records of these 3 months for different products. We will use cell values as these worksheet names in a formula as a reference to extract the values in a new sheet.

Excel use cell value as worksheet name in formula reference

Excel use cell value as worksheet name in formula reference

Excel use cell value as worksheet name in formula reference


Method 1 – Using the INDIRECT Function to Use Cell Value as Worksheet Name in a Formula Reference

We have the total sales value in cell D11 in each of the three sheets January, February, March.

Excel use cell value as worksheet name in formula reference

Excel use cell value as worksheet name in formula reference

INDIRECT function

We put the sheet names as cell values in a new sheet to use as references. Using the INDIRECT function, we will use these values as worksheet names in a formula and it will create a dynamic reference. Let’s get the total sales for each month (available in the three sheets).

INDIRECT function

Steps:

  • Insert the following formula in cell C4 of the new sheet:
=INDIRECT("'"&B4&"'"&"!"&"D11")

Here, B4 is the sheet name January and D11 is the cell in that sheet that contains the total sales value.

  • “‘”&B4&”‘”&”!”&”D11″ → & operator will join the cell value of B4 with inverted commas, exclamatory sign, and the cell reference D11
    Output → “‘January’!D11”
  • INDIRECT(“‘”&B4&”‘”&”!”&”D11″) becomes
    INDIRECT(“‘January’!D11”)
    Output → $23,084.00

INDIRECT function

  • Press Enter and drag down the Fill Handle tool.

INDIRECT function

  • You will get the total sales values corresponding to the sheet name references in the Sheet Name column.

INDIRECT function

Read More: How to Find and Replace Cell Reference in Excel Formula


Method 2 – Using INDIRECT and ADDRESS Functions to Use Cell Value as Worksheet Name

In the three sheets January, February, and March we have some records of sales for these months for different products.

Excel use cell value as worksheet name in formula reference

Excel use cell value as worksheet name in formula reference

Excel use cell value as worksheet name in formula reference

Let’s make a summary table where we will extract the sales values from those sheets and combine them in the January, February, and March columns.

INDIRECT and ADDRESS function

Steps:

  • Insert the following formula in cell C4:
=INDIRECT("'"&$C$3&"'"&"!"& ADDRESS(ROW(D4),COLUMN(D4)))

Here, $C$3 is the name of the worksheet.

  • ROW(D4) → returns the row number of the cell D4
    Output → 4
  • COLUMN(D4) → returns the column number of the cell D4
    Output → 4
  • ADDRESS(ROW(D4),COLUMN(D4)) becomes
    ADDRESS(4,4)
    Output → $D$4
  • INDIRECT(“‘”&$C$3&”‘”&”!”& ADDRESS(ROW(D4),COLUMN(D4))) becomes
    INDIRECT(“‘January’!”&”$D$4”) INDIRECT(“January!$D$4”)
    Output →$4,629.00

INDIRECT and ADDRESS function

  • Press Enter and drag down the Fill Handle Tool.

INDIRECT and ADDRESS function

  • You will get the sales record from the January sheet in the January column.

INDIRECT and ADDRESS function

  • For the February column, use the following formula in column D.
=INDIRECT("'"&$D$3&"'"&"!"& ADDRESS(ROW(D4),COLUMN(D4)))

Here, $D$3 is the name of the worksheet.

INDIRECT and ADDRESS function

  • Similarly, for the sales records of March use the following formula in column E.
=INDIRECT("'"&$E$3&"'"&"!"& ADDRESS(ROW(D4),COLUMN(D4)))

Here, $E$3 is the name of the worksheet.

INDIRECT and ADDRESS function

Read More: How to Use OFFSET for Cell Reference in Excel


Method 3 – Using VBA Code to Use Cell Value as Worksheet Name in a Formula Reference

Here, we have the total sales value in cell D11 in each of the three sheets January, February, March containing the sales records of January, February, and March.

Excel use cell value as worksheet name in formula reference

Excel use cell value as worksheet name in formula reference

VBA Code

In the Sheet Name column, we have put down the sheet names as cell values. Let’s get the total sales values from these sheets and gather them in the Total Sales column corresponding to their sheet names.

VBA Code

Steps:

  • Go to the Developer tab and select Visual Basic.

VBA Code

  • The Visual Basic Editor will open.
  • Go to the Insert tab and select Module.

VBA Code

  • This creates a blank Module.

VBA Code

  • Insert the following code into it:
Sub sheetreference()
Dim SheetR As String, ws As Worksheet, ws1 As Worksheet
Set ws = Worksheets("VBA")

For i = 4 To 6
SheetR = ws.Cells(i, 2).Value
Set ws1 = Sheets(SheetR)
ws.Cells(i, 3).Value = ws1.Range("D11").Value
Next i

End Sub

Here, we have declared SheetR as String, ws, and ws1 as Worksheet, ws will be assigned to the worksheet VBA where we will have our output. SheetR will store the cell values with sheet names in the VBA sheet. We have assigned the sheets January, February, and March to the variable ws1.

The FOR loop will extract the total sales values from each sheet to the VBA sheet, and here we have declared the range for this loop as 4 to 6 because the values start from Row 4 in the VBA sheet.

VBA Code

  • Press F5.
  • You will get the total sales values corresponding to the sheet name references in the Sheet Name column.

Excel use cell value as worksheet name in formula reference

Read More: How to Reference a Cell from a Different Worksheet in Excel


Typing the Worksheet Name for Using Reference in a Formula

Here, we will extract the total sales values from the sheets January, February, and March, and gather them in the Total Sales column in a new sheet.

Excel use cell value as worksheet name in formula reference

  • For the total sales value from January, use the following formula in cell C4:
=January!D11

Here, January is the sheet name and D11 is the total sales value in that sheet.

Typing sheet name

  • Similarly, for the sales value of the February month, use the following formula:
=February!D11

Here, February is the sheet name and D11 is the total sales value in that sheet.

Typing sheet name

If you don’t want to type any formula, you can just select the cell of the March sheet to extract that value in cell C6.

  • Type the equals sign (=) in cell C6.
  • Click on the March sheet.

Typing sheet name

  • You will be taken to the March sheet. Select the cell D11 in it.

Typing sheet name

  • Press Enter.
  • You will get the total sales value for March from that sheet in cell C6 in the Type sheet (the sample sheet we used).

Typing sheet name

Read More: How to Reference Cell in Another Sheet Dynamically in Excel


Practice Section

We have provided a Practice section in a sheet named Practice. Download the document below and follow the methods.

practice


Download Workbook


Related Articles


<< Go Back to Cell Reference in ExcelExcel Formulas | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Tanjima Hossain
Tanjima Hossain

TANJIMA HOSSAIN is a marine engineer who enjoys working with Excel and VBA programming. For her, programming is a handy, time-saving tool for managing data, files, and online tasks. She's skilled in Rhino3D, Maxsurf C++, MS Office, AutoCAD, and Excel & VBA, going beyond the basics. She holds a B.Sc. in Naval Architecture & Marine Engineering from BUET and is now a content developer. In this role, she creates tech-focused content centred around Excel and VBA. Apart from... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo