Search This Blog

Friday, May 25, 2018

How To Reference Same Cell From Multiple Worksheets In Excel?

At work I create multiple worksheets to store my weekly forecasts and was trying to plot a chart showing the evolution of my forecast week after week. For that I was looking for a way to automatically reference a cell from multiple worksheets on my excel file.

I am not an Excel VBA expert so was afraid the instructions I found here would not work but they did!
===========================================================
Extracted without consent since I was not sure how to ask, all credits should go to the original author of this posting referenced in the following url: https://www.extendoffice.com/documents/excel/1337-excel-reference-same-cell-different-sheet.html

How to reference Same Cell From Multiple Worksheets With some VBA Code

If there are dozens of worksheets, the copy and paste function will be troublesome and time-consuming, in this case, the following VBA code can help you fill the same cell references from multiple worksheets into one worksheet at once.
1. In the Master/last worksheet, click into a cell which is the same cell (same address, for instance C16) that you want to extract from other worksheets.
2. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
3. Click Insert > Module, and paste the following code in the Module Window.
VBA code: reference same cell from multiple worksheets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Sub AutoFillSheetNames()
'Update 20131202
Dim ActRng As Range
Dim ActWsName As String
Dim ActAddress As String
Dim Ws As Worksheet
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set ActRng = Application.ActiveCell
ActWsName = Application.ActiveSheet.Name
ActAddress = ActRng.Address(FalseFalse)
Application.ScreenUpdating = False
xIndex = 0
For Each Ws In Application.Worksheets
If Ws.Name <> ActWsName Then
ActRng.Offset(xIndex, 0).Value = "='" & Ws.Name & "'!" & ActAddress
xIndex = xIndex + 1
End If
Next
Application.ScreenUpdating = True
End Sub
4. Then press F5 key to run this code, and all values of that cell from other worksheets will been pulled down into the Master/latest worksheet.
Note: This VBA code is applied for filling the cells where you click. For example, if you click cell A1 in a specified worksheet, all the values of cell A1 from other worksheets will be filled into this worksheet.

No comments:

Labels

problems (8) windows 10 (7) Windows 7 (6) thunderbird (5) iPhone (3) Excel (2) MacOS (2) calendar (2) chrome (2) lightning (2) problem (2) tips (2) Apple on windows (1) Bluetooth (1) Costco (1) Disk Incentory X (1) Excel tips (1) GrandPerspective (1) MS Office (1) Mac (1) MacMini (1) Magic trackpad (1) Microsoft Compatibility Telemetry (1) N900 (1) Netgear (1) Office 2007 (1) OneNote (1) TWS (1) ThunderBrowse (1) Timezone (1) Trello on Thunderbird (1) Ventura (1) WNDR4500 (1) Web (1) WebPG (1) Window Maximize (1) Windows XP (1) adobe (1) associations (1) auto-complete (1) autocomplete (1) cell color (1) changes (1) conditional format (1) consolidation (1) day of the week (1) disabled (1) dish (1) dish network (1) disk (1) embedded document (1) excell (1) extension (1) file utilities (1) finger (1) fingerprint (1) firefox (1) folder consolidation (1) font (1) font size (1) forgot password (1) google sheets (1) high cpu usage (1) i7-TWS (1) iOS 10 (1) iPhone 5 (1) iPhone device (1) issue (1) itunes (1) japanese (1) java (1) keyboard (1) language (1) lock screen (1) log in problems (1) login problems (1) lower bill (1) mac os (1) magic mouse (1) mail (1) maximize (1) media server (1) mouse drifting (1) mouse problems (1) pdf (1) picture management (1) pictures (1) pivot table (1) portege z30-a (1) reading japanese (1) recovery (1) reduce (1) reference same cell (1) rename device (1) rikai (1) search (1) security (1) snipping (1) snipping tool (1) spotlight (1) telemetry (1) time (1) todo (1) toshiba (1) treemaps (1) unique values (1) update (1) utilities (1) weekday format (1) word (1) worksheets (1)