Created
December 24, 2017 20:23
-
-
Save summerofgeorge/6f8d4d949707f4df33d9c0af04546d3d to your computer and use it in GitHub Desktop.
Excel - Refresh data in locked worksheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'Refresh data in a protected worksheet | |
| 'Source: https://www.extendoffice.com/documents/excel/4379-excel-protect-sheet-but-allow-data-refresh.html | |
| 'Save workbook as .xlsm, hit Alt+F11, and paste the following code into the MODULES section of your workbook: | |
| Sub DataRefresh() | |
| ActiveSheet.Unprotect | |
| ActiveWorkbook.RefreshAll | |
| Application.OnTime Now + TimeValue("00:00:01"), "DataRefresh2" | |
| End Sub | |
| Sub DataRefresh2() | |
| If Application.CommandBars.GetEnabledMso("RefreshStatus") Then | |
| Application.OnTime Now + TimeValue("00:00:01"), " DataRefresh2" | |
| Else | |
| ActiveSheet.Protect | |
| End If | |
| End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment