{"id":11273,"date":"2019-11-04T16:51:09","date_gmt":"2019-11-04T15:51:09","guid":{"rendered":"https:\/\/www.myexcelonline.com\/?p=11273"},"modified":"2024-02-06T16:16:32","modified_gmt":"2024-02-06T15:16:32","slug":"protect-active-worksheet-using-macros-in-excel","status":"publish","type":"post","link":"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/protect-active-worksheet-using-macros-in-excel\/","title":{"rendered":"Protect Active Worksheet Using Macros In Excel"},"content":{"rendered":"<p>Wanted to protect your active worksheet programmatically? We will show you how to <strong>protect the active worksheet<\/strong> using <a class=\"wpil_keyword_link\" href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/101-excel-macros-examples\/\" target=\"_blank\" rel=\"noopener\" title=\"Macros\" data-wpil-keyword-link=\"linked\">Macros<\/a> in Excel!<\/p>\n<p>Make sure your Excel has the Developer Tab enabled following\u00a0<a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/how-to-create-your-first-macro-button-in-excel-beginners-tutorial\/\" target=\"_blank\" rel=\"noopener noreferrer\">this tutorial<\/a>.<\/p>\n<p>I explain how you can do this below step by step!<\/p>\n<p><em><strong>What does it do?<\/strong><\/em><\/p>\n<p>Protects the active worksheet with the password specified by the user<\/p>\n<p><em><strong>Copy Source Code:<\/strong><\/em><\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n\r\nSub ProtectActiveWorksheet()\r\n\r\nDim pword As String\r\n\r\n'Get the password from the user\r\npword = InputBox(&amp;quot;Enter a Password to Protect the Worksheet&amp;quot;)\r\n\r\n'Protect the Active Worksheet\r\nActiveSheet.Protect pword, True, True\r\nEnd Sub\r\n\r\n<\/pre>\n<p><em><strong>Final Result:\u00a0<\/strong><\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Protect Active Worksheet Using Macros In Excel\"  class=\"aligncenter size-full wp-image-11923\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-05.jpg\" alt=\"Protect Active Worksheet Using Macros In Excel\" width=\"1513\" height=\"738\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-05.jpg 1513w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-05-300x146.jpg 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-05-1024x499.jpg 1024w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-05-768x375.jpg 768w\" sizes=\"(max-width: 1513px) 100vw, 1513px\" \/><\/p>\n<p><em><strong>Exercise Workbook:<\/strong><\/em><\/p>\n<div class=\"after-post-box\">\n<p><iframe src=\"https:\/\/www.youtube.com\/embed\/DRD_HjICJBM?rel=0 \" width=\"800\" height=\"400\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe><a href=\"https:\/\/www.youtube.com\/c\/MyExcelOnlinecomtutorials?sub_confirmation=1\" target=\"_blank\" rel=\"noopener noreferrer nofollow\"><img loading=\"lazy\" decoding=\"async\" class=\"alignmiddle wp-image-111468 size-full\" style=\"vertical-align: middle;\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/1.yt_.png\" alt=\"\" title=\"\"><\/a><\/p>\n<p class=\"line-two\"><a class=\"IRPP_minimalist icon-download button small\" href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet.xlsm\" target=\"_blank\" rel=\"noopener noreferrer\" data-leadbox=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet.xlsm\" data-leadbox-id=\"147284833f72a2:12f08263ab46dc\"><span class=\"ctaText px-3 text-capitalize\">Download excel workbook<i class=\"fa fa-download\"><\/i><\/span><span class=\"postTitle px-3\">Protect-Active-Worksheet.xlsm<\/span><\/a><\/p>\n<p class=\"line-two\">\n<\/div>\n<hr \/>\n<p>Here are our worksheets:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Protect Active Worksheet Using Macros In Excel\"  class=\"aligncenter size-full wp-image-11919\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-01.jpg\" alt=\"Protect Active Worksheet Using Macros In Excel\" width=\"322\" height=\"78\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-01.jpg 322w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-01-300x73.jpg 300w\" sizes=\"(max-width: 322px) 100vw, 322px\" \/><\/p>\n<p><span style=\"color: #ff0000;\"><strong>STEP 1:<\/strong><\/span>\u00a0Go to\u00a0<em><strong>Developer &gt; Code &gt; Visual Basic<\/strong><\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-10906 aligncenter\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/01\/How-to-Insert-Multiple-Columns-01.jpg\" alt=\"\" width=\"816\" height=\"139\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/01\/How-to-Insert-Multiple-Columns-01.jpg 816w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/01\/How-to-Insert-Multiple-Columns-01-300x51.jpg 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/01\/How-to-Insert-Multiple-Columns-01-768x131.jpg 768w\" sizes=\"(max-width: 816px) 100vw, 816px\" title=\"\"><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\"><strong>STEP 2:<\/strong><\/span>\u00a0Paste in your code and\u00a0<strong>Select Save<\/strong>. Close the window afterwards.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Protect Active Worksheet Using Macros In Excel\"  class=\"aligncenter size-full wp-image-11920\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-02.jpg\" alt=\"Protect Active Worksheet Using Macros In Excel\" width=\"1641\" height=\"428\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-02.jpg 1641w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-02-300x78.jpg 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-02-1024x267.jpg 1024w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-02-768x200.jpg 768w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-02-1536x401.jpg 1536w\" sizes=\"(max-width: 1641px) 100vw, 1641px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\"><strong>STEP 3:\u00a0<\/strong><\/span>Let us test it out!<\/p>\n<p>Select your sheet to protect. For our example let us select the\u00a0<strong>Americas\u00a0<\/strong>worksheet.<\/p>\n<p>Go to\u00a0<em><strong>Developer &gt; Code &gt; Macros<\/strong><\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11245\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Unmerge-Cells-02.jpg\" alt=\"\" width=\"854\" height=\"142\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Unmerge-Cells-02.jpg 854w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Unmerge-Cells-02-300x50.jpg 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Unmerge-Cells-02-768x128.jpg 768w\" sizes=\"(max-width: 854px) 100vw, 854px\" title=\"\"><\/p>\n<p>Make sure your <a class=\"wpil_keyword_link\" href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/101-excel-macros-examples\/\" target=\"_blank\" rel=\"noopener\" title=\"macro\" data-wpil-keyword-link=\"linked\">macro<\/a> is selected. Click <strong>Run<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Protect Active Worksheet Using Macros In Excel\"  class=\"aligncenter size-full wp-image-11921\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-03.jpg\" alt=\"Protect Active Worksheet Using Macros In Excel\" width=\"1077\" height=\"712\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-03.jpg 1077w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-03-300x198.jpg 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-03-1024x677.jpg 1024w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-03-768x508.jpg 768w\" sizes=\"(max-width: 1077px) 100vw, 1077px\" \/><\/p>\n<p>Type in the password to protect the worksheet.\u00a0<strong>Click OK.<\/strong><\/p>\n<p><span style=\"color: #0000ff;\"><strong><img loading=\"lazy\" decoding=\"async\" title=\"Protect Active Worksheet Using Macros In Excel\"  class=\"aligncenter size-full wp-image-11922\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-04.jpg\" alt=\"Protect Active Worksheet Using Macros In Excel\" width=\"597\" height=\"250\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-04.jpg 597w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-04-300x126.jpg 300w\" sizes=\"(max-width: 597px) 100vw, 597px\" \/><\/strong><\/span><\/p>\n<p>Try editing your worksheet. You can verify that\u00a0<strong>the worksheet is now protected<\/strong>!<\/p>\n<p><span style=\"color: #0000ff;\"><strong>\u00a0<img loading=\"lazy\" decoding=\"async\" title=\"Protect Active Worksheet Using Macros In Excel\"  class=\"aligncenter size-full wp-image-11923\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-05.jpg\" alt=\"Protect Active Worksheet Using Macros In Excel\" width=\"1513\" height=\"738\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-05.jpg 1513w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-05-300x146.jpg 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-05-1024x499.jpg 1024w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/03\/Protect-Active-Worksheet-05-768x375.jpg 768w\" sizes=\"(max-width: 1513px) 100vw, 1513px\" \/><\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #0000ff;\"><strong>How to Protect Active Worksheet Using Macros In Excel<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/100-66.html\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13266\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/10\/101-Macros-Book.png\" alt=\"101 Macros Book\" width=\"1200\" height=\"628\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/10\/101-Macros-Book.png 1200w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/10\/101-Macros-Book-300x157.png 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/10\/101-Macros-Book-1024x536.png 1024w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/10\/101-Macros-Book-768x402.png 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wanted to protect your active worksheet programmatically? We will show you how to protect the active worksheet using Macros in Excel! Make sure your Excel has the Developer Tab enabled following\u00a0this tutorial. I explain how you can do this below step by step! What does it do? Protects the active worksheet with the password specified [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":18102,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"cos_headline_score":0,"cos_seo_score":0,"cos_headline_text":"","cos_headline_has_been_analyzed":false,"cos_last_analyzed_headline":[],"om_disable_all_campaigns":false},"categories":[56,646],"tags":[106],"acf":[],"_links":{"self":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/posts\/11273"}],"collection":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/comments?post=11273"}],"version-history":[{"count":0,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/posts\/11273\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/media\/18102"}],"wp:attachment":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/media?parent=11273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/categories?post=11273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/tags?post=11273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}