{"id":14834,"date":"2018-06-28T21:44:10","date_gmt":"2018-06-28T21:44:10","guid":{"rendered":"http:\/\/learnexcelmacro.com\/wp\/?p=14834"},"modified":"2022-08-17T19:17:00","modified_gmt":"2022-08-17T19:17:00","slug":"40-useful-excel-macro-examples-for-beginners-part-2-of-2","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/","title":{"rendered":"40 Useful Excel Macro [VBA] examples – Part 2 of 2 [ FREE DOWNLOAD ]"},"content":{"rendered":"

[et_pb_section fb_built=”1″ _builder_version=”4.17.6″ custom_padding=”0px|0px|0px|0px|false|false” da_disable_devices=”off|off|off” global_colors_info=”{}” da_is_popup=”off” da_exit_intent=”off” da_has_close=”on” da_alt_close=”off” da_dark_close=”off” da_not_modal=”on” da_is_singular=”off” da_with_loader=”off” da_has_shadow=”on”][et_pb_row use_custom_gutter=”on” gutter_width=”1″ _builder_version=”4.17.6″ background_size=”initial” background_position=”top_left” background_repeat=”repeat” width=”100%” custom_padding=”0px|0px|0px|0px|false|false” global_colors_info=”{}”][et_pb_column type=”4_4″ _builder_version=”4.16″ custom_padding=”|||” global_colors_info=”{}” custom_padding__hover=”|||”][et_pb_text _builder_version=”4.17.6″ background_size=”initial” background_position=”top_left” background_repeat=”repeat” custom_padding=”0px|0px|0px|0px|false|false” global_colors_info=”{}”]<\/p>\n

Dear friends,<\/p>\n

As you see this is the second and last part of the tutorial 40 Useful Excel Macro [VBA] examples<\/a><\/strong>. In a previous article,<\/strong><\/a> I published the first 20 examples.<\/p>\n

Download a FREE Excel Workbook with all 40 Examples<\/h3>\n

At the end of this article, you will have a link to download a FREE copy of all 40 useful excel macros collections. Do not forget to download and play around and do provide your feedback.<\/p>\n

Here in this last part remaining 20 examples are specified here.<\/p>\n

\n
    \n
  1. Insert a row in a worksheet using Excel Macro<\/a><\/li>\n
  2. Insert a column in a worksheet using Excel Macro<\/a><\/li>\n
  3. Delete a row in a worksheet using Excel Macro<\/a><\/li>\n
  4. Delete a column in a worksheet using Excel Macro<\/a><\/li>\n
  5. Hide a row in worksheet using Excel Macro<\/a><\/li>\n
  6. Hide a column in worksheet using Excel Macro<\/a><\/li>\n
  7. Unhide a row in worksheet using Excel Macro <\/a><\/li>\n
  8. Unhide a column in worksheet using Excel Macro<\/a><\/li>\n
  9. Copy and insert copied row before a specific row using Excel Macro<\/a><\/li>\n
  10. Copy and insert copied column before a specific column using Excel Macro<\/a><\/li>\n
  11. Protect a worksheet without any password using Excel Macro<\/a><\/li>\n
  12. Protect a worksheet with a password using Excel Macro<\/a><\/li>\n
  13. Unprotect a protected worksheet using Excel Macro<\/a><\/li>\n
  14. Unprotect a password protected worksheet using Excel Macro<\/a><\/li>\n
  15. Protect a workbook with password using Excel Macro<\/a><\/li>\n
  16. Open a password protected workbook using Excel Macro<\/a><\/li>\n
  17. Clear contents of a Range without clearing formatting using Excel Macro<\/a><\/li>\n
  18. Clear content of a range with formatting using Excel Macro<\/a><\/li>\n
  19. Clear contents of a worksheet using Excel Macro<\/a><\/li>\n
  20. Clear all the comments using Excel Macro<\/a><\/li>\n<\/ol>\n<\/div>\n

    1. Excel Macro to insert a row in a worksheet<\/h2>\n

    Use the following piece of code to insert a single row or multiple rows in a worksheet.
    Note:<\/em><\/strong> Do not miss reading the comments specified inside the code. They are important to know more about the code.<\/p>\n

    \n\n    Sub insertRowInWorksheet()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' insert row at a specific row number\n    sh.Rows(4).Insert\n    \n    ' insert more than 1 row starting from a specific\n    ' row. In below example there will be 3 rows\n    ' inserted starting from row 3\n    ' existing row 3rd will be shifted to 6th position\n    sh.Rows(\"3:5\").EntireRow.Insert\n    \n    ' insert row below the selected cell\n    ActiveCell.Rows.Insert\n    \n    End Sub\n<\/code><\/pre>\n

    2. Excel Macro to insert a column in a worksheet<\/h2>\n

    Following code can be used to insert a single column or multiple columns in a worksheet.<\/p>\n

    \n    Sub insertColumnInWorksheet()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' insert column at a specific column name\n    sh.Columns(B).Insert\n    \n    ' insert more than 1 column starting from a specific\n    ' column. In below example there will be 3 columns\n    ' inserted starting from column A\n    sh.Columns(\"A:C\").Insert\n    \n    End Sub\n<\/code><\/pre>\n

     <\/p>\n

    3. Excel Macro to delete a row in a worksheet<\/h2>\n

    Using this code you can delete a single or multiple rows.<\/p>\n

    \n    Sub deleteRowInWorksheet()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' delete a specific row \n\t' row no:2 will be deleted\n    sh.Rows(2).Delete\n    \n    ' delete more than one row\n\t' below statement will delete\n\t' all the rows 3, 4 and 5\n    sh.Rows(\"3:5\").Delete\n        \n    End Sub\n<\/code><\/pre>\n

     <\/p>\n

    4. Excel Macro to delete a column in a worksheet<\/h2>\n

    Using the below piece of code, you can delete a single or multiple columns.<\/p>\n

    \n    Sub deleteColumnInWorksheet()\n\n    End Sub\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' delete a specific column\n    sh.Columns(B).Delete\n    \n    ' delete more than one column\n\t' All the columns A, B and C will be deleted\n\t' at once by below statement\n    sh.Columns(\"A:C\").Delete\n    End Sub\n    <\/code><\/pre>\n

     <\/p>\n

    5. Excel Macro to hide a row in worksheet<\/h2>\n

    Using the below piece of code, you can hide a single or multiple rows.<\/p>\n

    \n    Sub hideRowInWorksheet()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' hide a specific row by providing the row number\n    sh.Rows(2).Hidden = True\n    \n    ' hide more than one row at once\n\t' following statement will hide all\n\t' the rows 3, 4 and 5\n    sh.Rows(\"3:5\").Hidden = True\n        \n    End Sub\n<\/code><\/pre>\n

     <\/p>\n

    6. Excel Macro to hide a column in worksheet<\/h2>\n

    Using the below piece of code, you can hide a single or multiple columns.<\/p>\n

    \n    Sub hideColumnInWorksheet()\n\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' hide a specific column\n\t' column C will be hidden by this statement\n    sh.Columns(\"C\").Hidden = True\n    \n    ' hide multiple columns using the below statement\n\t' below statement will hide all the columns\n\t' A, B and C\n    sh.Columns(\"A:C\").Hidden = True\n    End Sub\n    <\/code><\/pre>\n

     <\/p>\n

    7. Excel Macro to unhide a row in worksheet<\/h2>\n

    Using the below piece of code, you can unhide a single or multiple rows.<\/p>\n

    \n    Sub unhideRowInWorksheet()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' unhide a specific hidden row\n    sh.Rows(2).Hidden = False\n    \n    ' unhide more than 1 hidden rows \n\t' following statement will unhide \n\t' all the rows from 3 to 5\n    sh.Rows(\"3:5\").Hidden = False\n        \n    End Sub\n<\/code><\/pre>\n

     <\/p>\n

    8. how to unhide a column in worksheet<\/h2>\n

    Using the below piece of code, you can unhide a single or multiple columns.<\/p>\n

    \n    Sub unhideColumnInWorksheet()\n\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' unhide a specific hidden column\n    sh.Columns(\"C\").Hidden = False\n    \n    ' unhide multiple columns at once\n\t' multiple columns will be made visible \n\t' by the below statement - A, B and C\n    sh.Columns(\"A:C\").Hidden = False\n    End Sub\n<\/code><\/pre>\n\n

     <\/p>\n

    9. Excel Macro to copy and insert copied single or multiple rows before a specific row<\/h2>\n

    Using the below piece of code, you can copy and insert any number of rows.<\/p>\n

    \n    Sub CopyAndInsertCopiedRow()\n\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' Copy 2nd row and insert this copied row at 10th row\n    sh.Rows(2).EntireRow.Copy\n    ' below statement by default paste the copied row\n    ' exactly at the 10th row and rest of the rows\n    ' will be shifted down\n    sh.Rows(10).Insert\n    \n    ' copy more than one row and insert them all\n    ' at a specific row\n    ' Copy rows from 2 to 5 and paste them\n    ' on 10th row. Excel will by default automatically\n    ' shift that many rows down\n    sh.Rows(\"2:5\").EntireRow.Copy\n    sh.Rows(10).Insert\n    End Sub\n<\/code><\/pre>\n

     <\/p>\n

    10. Excel macro to copy and insert copied column before a specific column<\/h2>\n
    \n    Sub CopyAndInsertCopiedColumn()\n\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' Copy Column A and insert this copied column at Column D\n    sh.Columns(\"A\").EntireColumn.Copy\n    ' below statement by default paste the copied column\n    ' exactly at the Column - D and rest of the columns\n    ' will be shifted right\n    sh.Columns(\"D\").Insert\n    \n    ' copy more than one column and insert them all\n    ' at a specific column\n    ' Example: Copy columns from A to D and paste them\n    ' on column F. Excel will by default automatically\n    ' shift that many columns right\n    sh.Columns(\"A:D\").EntireColumn.Copy\n    sh.Columns(\"F\").Insert\n    End Sub\n    <\/code><\/pre>\n

     <\/p>\n

    11. Excel Macro to protect a worksheet without any password<\/h2>\n
    \n    Sub protectSheetWithoutPassword()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' protect this one sheet sh without any password\n    sh.Protect\n    End Sub\n    <\/code><\/pre>\n

     <\/p>\n

    12. Excel Macro to protect a worksheet with a password<\/h2>\n
    \n    Sub protectSheetWithPassword()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' protect this one sheet sh without a very strong password\n    ' like i have given below ;)\n    sh.Protect Password:=\"password123\"\n    End Sub\n    <\/code><\/pre>\n

     <\/p>\n

    13. Excel Macro to unprotect a protected worksheet<\/h2>\n
    \n    Sub unprotectSheetWithoutPassword()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' unprotect a protected sheet which is not\n    ' protected without giving any password\n    sh.Unprotect\n    End Sub\n    <\/code><\/pre>\n

     <\/p>\n

    14. Excel Macro to unprotect a password protected worksheet<\/h2>\n
    \n    Sub unprotectSheetWithPassword()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' unprotect a protected sheet which is not\n    ' protected without giving any password\n    sh.Unprotect Password:=\"password123\"\n    End Sub\n    <\/code><\/pre>\n

     <\/p>\n

    15. Excel Macro to protect a workbook with password<\/h2>\n
    \n    Sub protectWorkbookWithPassword()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim newFileName As String\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    newFileName = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    \n    ' .saveAs provides a feature in excel vba\n    ' to provide a password which will be asked\n    ' when you try to open it again\n    wb.SaveAs Filename:=newFileName, Password:=\"password123\"\n        \n    End Sub\n<\/code><\/pre>\n

     <\/p>\n

    16. Excel Macro to open a password protected workbook<\/h2>\n
    \n    Sub OpenProtectedWorkbookWithPassword()\n    Dim wb As Workbook\n    Dim fPath As String\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath, Password:=\"password123\")\n    ' now you can use this workbook as normal\n    End Sub\n<\/code><\/pre>\n

     <\/p>\n

    17. Excel Macro to clear contents of a Range without clearing formatting<\/h2>\n
    \n    Sub ClearContentOfRangeWithoutClearingFormatting()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' following statement will clear all the contents\n    ' of 1st Range A1 to X5. This will keep the\n    ' formatting as it is\n    sh.Range(\"A1:X5\").ClearContents\n    End Sub\n    <\/code><\/pre>\n

     <\/p>\n

    18. Excel Macro to clear content of a range with formatting<\/h2>\n
    \n    Sub ClearContentAndFormatting()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' following statement will clear all the contents\n    ' as well as any formatting done on these cells\n    sh.Range(\"A1:P27\").Clear\n    End Sub\n    <\/code><\/pre>\n

     <\/p>\n

    19. Excel Macro to clear contents of a worksheet<\/h2>\n
    \n    Sub ClearContentOfWorksheet()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' To clear all contents + formatting together\n    sh.UsedRange.Clear\n    \n    ' To clear all contents ONLY\n    sh.UsedRange.ClearContents\n    End Sub\n<\/code><\/pre>\n

     <\/p>\n

    20. Excel Macro to clear all the comments<\/h2>\n
    \n\n    Sub ClearAllComments()\n    Dim wb As Workbook\n    Dim fPath As String\n    Dim sh As Worksheet\n    \n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\n    Set wb = Workbooks.Open(Filename:=fPath)\n    Set sh = wb.Worksheets(1)\n    ' following statement will clear all the contents\n    ' as well as any formatting done on these cells\n    sh.Range(\"A1:P27\").ClearComments\n    End Sub\n<\/code><\/pre>\n

    [\/et_pb_text][et_pb_cta title=”How did you find this collection of 40 Excel Macro examples?” button_url=”\/excel\/wp-content\/downloads\/Top-40-Useful-ExcelMacro-Examples.xlsm” button_text=”Download FREE Workbook” _builder_version=”4.17.6″ _module_preset=”a50a16dd-d05f-4ea2-acab-1468d2e4010e” global_colors_info=”{}”]Did you find them useful to you? Provide your feedback about this. I will write more of such articles with more and more useful and simple Excel VBA Macro examples.<\/p>\n

    Download your Excel File with all 40 Useful Macro Collection<\/h4>\n

    [\/et_pb_cta][et_pb_blurb title=”You may like reading them too” use_icon=”on” font_icon=”||fa||900″ _builder_version=”4.17.6″ _module_preset=”0249c68e-4de8-4f44-84ff-a9b1850785b6″ hover_enabled=”0″ global_colors_info=”{}” sticky_enabled=”0″]<\/p>\n

      \n
    1. Difference between Sheets and Worksheets in Excel Macro<\/a><\/li>\n
    2. VBA to Open or Create a Password Protected Workbook<\/a><\/li>\n
    3. Excel Macro : Excel VBA code to Protect OR UnProtect Sheet(Opens in a new browser tab)
      \n<\/a><\/li>\n
    4. 40 Useful Excel Macro [VBA] examples – Part 1 of 2<\/a><\/li>\n
    5. Excel Trick – Sheet Protection – Protect it and Stay Free<\/a><\/li>\n<\/ol>\n

      [\/et_pb_blurb][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n<\/span>","protected":false},"excerpt":{"rendered":"

      Dear friends, As you see this is the second and last part of the tutorial 40 Useful Excel Macro [VBA] examples. In a previous article, I published the first 20 examples. Download a FREE Excel Workbook with all 40 Examples At the end of this article, you will have a link to download a FREE […]<\/p>\n","protected":false},"author":45,"featured_media":242874,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"

      Dear friends,<\/p>

      As you see this is the second and last part of the tutorial 40 Useful Excel Macro [VBA] examples<\/a><\/strong>. In a previous article,<\/strong><\/a> I published the first 20 examples.<\/p>

      Download a FREE Excel Workbook with all 40 Examples<\/h3>

      At the end of this article, you will have a link to download a FREE copy of all 40 useful excel macros collections. Do not forget to download and play around and do provide your feedback.<\/p>

      Here in this last part remaining 20 examples are specified here.<\/p>

      1. 1. Insert a row in a worksheet using Excel Macro<\/a><\/li>
      2. 2. Insert a column in a worksheet using Excel Macro<\/a><\/li>
      3. 3. Delete a row in a worksheet using Excel Macro<\/a><\/li>
      4. 4. Delete a column in a worksheet using Excel Macro<\/a><\/li>
      5. 5. Hide a row in worksheet using Excel Macro<\/a><\/li>
      6. 6. Hide a column in worksheet using Excel Macro<\/a><\/li>
      7. 7. Unhide a row in worksheet using Excel Macro <\/a><\/li>
      8. 8. Unhide a column in worksheet using Excel Macro<\/a><\/li>
      9. 9. Copy and insert copied row before a specific row using Excel Macro<\/a><\/li>
      10. 10. Copy and insert copied column before a specific column using Excel Macro<\/a><\/li>
      11. 11. Protect a worksheet without any password using Excel Macro<\/a><\/li>
      12. 12. Protect a worksheet with a password using Excel Macro<\/a><\/li>
      13. 13. Unprotect a protected worksheet using Excel Macro<\/a><\/li>
      14. 14. Unprotect a password protected worksheet using Excel Macro<\/a><\/li>
      15. 15. Protect a workbook with password using Excel Macro<\/a><\/li>
      16. 16. Open a password protected workbook using Excel Macro<\/a><\/li>
      17. 17. Clear contents of a Range without clearing formatting using Excel Macro<\/a><\/li>
      18. 18. Clear content of a range with formatting using Excel Macro<\/a><\/li>
      19. 19. Clear contents of a worksheet using Excel Macro<\/a><\/li>
      20. 20. Clear all the comments using Excel Macro<\/a><\/li><\/ol><\/div>

        1. Excel Macro to insert a row in a worksheet<\/h2>

        Use the following piece of code to insert a single row or multiple rows in a worksheet.
        Note:<\/em><\/strong> Do not miss reading the comments specified inside the code. They are important to know more about the code.<\/p>

        \r\n\r\n    Sub insertRowInWorksheet()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' insert row at a specific row number\r\n    sh.Rows(4).Insert\r\n    \r\n    ' insert more than 1 row starting from a specific\r\n    ' row. In below example there will be 3 rows\r\n    ' inserted starting from row 3\r\n    ' existing row 3rd will be shifted to 6th position\r\n    sh.Rows(\"3:5\").EntireRow.Insert\r\n    \r\n    ' insert row below the selected cell\r\n    ActiveCell.Rows.Insert\r\n    \r\n    End Sub\r\n<\/code><\/pre>

        2. Excel Macro to insert a column in a worksheet<\/h2>

        Following code can be used to insert a single column or multiple columns in a worksheet.<\/p>

        \r\n    Sub insertColumnInWorksheet()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' insert column at a specific column name\r\n    sh.Columns(B).Insert\r\n    \r\n    ' insert more than 1 column starting from a specific\r\n    ' column. In below example there will be 3 columns\r\n    ' inserted starting from column A\r\n    sh.Columns(\"A:C\").Insert\r\n    \r\n    End Sub\r\n<\/code><\/pre>

        \u00a0<\/p>

        3. Excel Macro to delete a row in a worksheet<\/h2>

        Using this code you can delete a single or multiple rows.<\/p>

        \r\n    Sub deleteRowInWorksheet()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' delete a specific row \r\n\t' row no:2 will be deleted\r\n    sh.Rows(2).Delete\r\n    \r\n    ' delete more than one row\r\n\t' below statement will delete\r\n\t' all the rows 3, 4 and 5\r\n    sh.Rows(\"3:5\").Delete\r\n        \r\n    End Sub\r\n<\/code><\/pre>

        \u00a0<\/p>

        4. Excel Macro to delete a column in a worksheet<\/h2>

        Using the below piece of code, you can delete a single or multiple columns.<\/p>

        \r\n    Sub deleteColumnInWorksheet()\r\n\r\n    End Sub\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' delete a specific column\r\n    sh.Columns(B).Delete\r\n    \r\n    ' delete more than one column\r\n\t' All the columns A, B and C will be deleted\r\n\t' at once by below statement\r\n    sh.Columns(\"A:C\").Delete\r\n    End Sub\r\n    <\/code><\/pre>

        \u00a0<\/p>

        5. Excel Macro to hide a row in worksheet<\/h2>

        Using the below piece of code, you can hide a single or multiple rows.<\/p>

        \r\n    Sub hideRowInWorksheet()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' hide a specific row by providing the row number\r\n    sh.Rows(2).Hidden = True\r\n    \r\n    ' hide more than one row at once\r\n\t' following statement will hide all\r\n\t' the rows 3, 4 and 5\r\n    sh.Rows(\"3:5\").Hidden = True\r\n        \r\n    End Sub\r\n<\/code><\/pre>

        \u00a0<\/p>

        6. Excel Macro to hide a column in worksheet<\/h2>

        Using the below piece of code, you can hide a single or multiple columns.<\/p>

        \r\n    Sub hideColumnInWorksheet()\r\n\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' hide a specific column\r\n\t' column C will be hidden by this statement\r\n    sh.Columns(\"C\").Hidden = True\r\n    \r\n    ' hide multiple columns using the below statement\r\n\t' below statement will hide all the columns\r\n\t' A, B and C\r\n    sh.Columns(\"A:C\").Hidden = True\r\n    End Sub\r\n    <\/code><\/pre>

        \u00a0<\/p>

        7. Excel Macro to unhide a row in worksheet<\/h2>

        Using the below piece of code, you can unhide a single or multiple rows.<\/p>

        \r\n    Sub unhideRowInWorksheet()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' unhide a specific hidden row\r\n    sh.Rows(2).Hidden = False\r\n    \r\n    ' unhide more than 1 hidden rows \r\n\t' following statement will unhide \r\n\t' all the rows from 3 to 5\r\n    sh.Rows(\"3:5\").Hidden = False\r\n        \r\n    End Sub\r\n<\/code><\/pre>

        \u00a0<\/p>

        8. how to unhide a column in worksheet<\/h2>

        Using the below piece of code, you can unhide a single or multiple columns.<\/p>

        \r\n    Sub unhideColumnInWorksheet()\r\n\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' unhide a specific hidden column\r\n    sh.Columns(\"C\").Hidden = False\r\n    \r\n    ' unhide multiple columns at once\r\n\t' multiple columns will be made visible \r\n\t' by the below statement - A, B and C\r\n    sh.Columns(\"A:C\").Hidden = False\r\n    End Sub\r\n<\/code><\/pre>

        [widget id=\"text-48\"]<\/p>

        \u00a0<\/p>

        9. Excel Macro to copy and insert copied single or multiple rows before a specific row<\/h2>

        Using the below piece of code, you can copy and insert any number of rows.<\/p>

        \r\n    Sub CopyAndInsertCopiedRow()\r\n\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' Copy 2nd row and insert this copied row at 10th row\r\n    sh.Rows(2).EntireRow.Copy\r\n    ' below statement by default paste the copied row\r\n    ' exactly at the 10th row and rest of the rows\r\n    ' will be shifted down\r\n    sh.Rows(10).Insert\r\n    \r\n    ' copy more than one row and insert them all\r\n    ' at a specific row\r\n    ' Copy rows from 2 to 5 and paste them\r\n    ' on 10th row. Excel will by default automatically\r\n    ' shift that many rows down\r\n    sh.Rows(\"2:5\").EntireRow.Copy\r\n    sh.Rows(10).Insert\r\n    End Sub\r\n<\/code><\/pre>

        \u00a0<\/p>

        10. Excel macro to copy and insert copied column before a specific column<\/h2>
        \r\n    Sub CopyAndInsertCopiedColumn()\r\n\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' Copy Column A and insert this copied column at Column D\r\n    sh.Columns(\"A\").EntireColumn.Copy\r\n    ' below statement by default paste the copied column\r\n    ' exactly at the Column - D and rest of the columns\r\n    ' will be shifted right\r\n    sh.Columns(\"D\").Insert\r\n    \r\n    ' copy more than one column and insert them all\r\n    ' at a specific column\r\n    ' Example: Copy columns from A to D and paste them\r\n    ' on column F. Excel will by default automatically\r\n    ' shift that many columns right\r\n    sh.Columns(\"A:D\").EntireColumn.Copy\r\n    sh.Columns(\"F\").Insert\r\n    End Sub\r\n    <\/code><\/pre>

        \u00a0<\/p>

        11. Excel Macro to protect a worksheet without any password<\/h2>
        \r\n    Sub protectSheetWithoutPassword()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' protect this one sheet sh without any password\r\n    sh.Protect\r\n    End Sub\r\n    <\/code><\/pre>

        \u00a0<\/p>

        12. Excel Macro to protect a worksheet with a password<\/h2>
        \r\n    Sub protectSheetWithPassword()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' protect this one sheet sh without a very strong password\r\n    ' like i have given below ;)\r\n    sh.Protect Password:=\"password123\"\r\n    End Sub\r\n    <\/code><\/pre>

        \u00a0<\/p>

        13. Excel Macro to unprotect a protected worksheet<\/h2>
        \r\n    Sub unprotectSheetWithoutPassword()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' unprotect a protected sheet which is not\r\n    ' protected without giving any password\r\n    sh.Unprotect\r\n    End Sub\r\n    <\/code><\/pre>

        \u00a0<\/p>

        14. Excel Macro to unprotect a password protected worksheet<\/h2>
        \r\n    Sub unprotectSheetWithPassword()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' unprotect a protected sheet which is not\r\n    ' protected without giving any password\r\n    sh.Unprotect Password:=\"password123\"\r\n    End Sub\r\n    <\/code><\/pre>

        \u00a0<\/p>

        15. Excel Macro to protect a workbook with password<\/h2>
        \r\n    Sub protectWorkbookWithPassword()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim newFileName As String\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    newFileName = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    \r\n    ' .saveAs provides a feature in excel vba\r\n    ' to provide a password which will be asked\r\n    ' when you try to open it again\r\n    wb.SaveAs Filename:=newFileName, Password:=\"password123\"\r\n        \r\n    End Sub\r\n<\/code><\/pre>

        \u00a0<\/p>

        16. Excel Macro to open a password protected workbook<\/h2>
        \r\n    Sub OpenProtectedWorkbookWithPassword()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath, Password:=\"password123\")\r\n    ' now you can use this workbook as normal\r\n    End Sub\r\n<\/code><\/pre>

        \u00a0<\/p>

        17. Excel Macro to clear contents of a Range without clearing formatting<\/h2>
        \r\n    Sub ClearContentOfRangeWithoutClearingFormatting()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' following statement will clear all the contents\r\n    ' of 1st Range A1 to X5. This will keep the\r\n    ' formatting as it is\r\n    sh.Range(\"A1:X5\").ClearContents\r\n    End Sub\r\n    <\/code><\/pre>

        \u00a0<\/p>

        18. Excel Macro to clear content of a range with formatting<\/h2>
        \r\n    Sub ClearContentAndFormatting()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' following statement will clear all the contents\r\n    ' as well as any formatting done on these cells\r\n    sh.Range(\"A1:P27\").Clear\r\n    End Sub\r\n    <\/code><\/pre>

        \u00a0<\/p>

        19. Excel Macro to clear contents of a worksheet<\/h2>
        \r\n    Sub ClearContentOfWorksheet()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' To clear all contents + formatting together\r\n    sh.UsedRange.Clear\r\n    \r\n    ' To clear all contents ONLY\r\n    sh.UsedRange.ClearContents\r\n    End Sub\r\n<\/code><\/pre>

        \u00a0<\/p>

        20. Excel Macro to clear all the comments<\/h2>
        \r\n\r\n    Sub ClearAllComments()\r\n    Dim wb As Workbook\r\n    Dim fPath As String\r\n    Dim sh As Worksheet\r\n    \r\n    fPath = \"C:\\Users\\vmishra\\Desktop\\myfile.xlsx\"\r\n    Set wb = Workbooks.Open(Filename:=fPath)\r\n    Set sh = wb.Worksheets(1)\r\n    ' following statement will clear all the contents\r\n    ' as well as any formatting done on these cells\r\n    sh.Range(\"A1:P27\").ClearComments\r\n    End Sub\r\n<\/code><\/pre>

        \u00a0<\/p>

        How did you find this collection of 40 Excel Macro examples? Did you find them useful to you? Provide your feedback about this. I will write more of such articles with more and more useful and simple Excel VBA Macro examples.<\/p>

        Download your Excel File with all 40 Useful Macro Collection<\/h2>

        \u00a0<\/p>

        [button link=\"\/excel\/wp-content\/downloads\/Top-40-Useful-ExcelMacro-Examples.xlsm\" color=\"default\" size=\"\" stretch=\"\" type=\"\" shape=\"\" target=\"_blank\" title=\"\" gradient_colors=\"|\" gradient_hover_colors=\"|\" accent_color=\"\" accent_hover_color=\"\" bevel_color=\"\" border_width=\"\" icon=\"fa-download\" icon_position=\"right\" icon_divider=\"yes\" modal=\"\" animation_type=\"0\" animation_direction=\"left\" animation_speed=\"1\" animation_offset=\"\" alignment=\"center\" class=\"\" id=\"\"]DOWNLOAD -TOP 40 Excel Macro Examples Collection Workbook[\/button]<\/p><\/div>","_et_gb_content_width":"","footnotes":""},"categories":[1246,1679,1675,1682],"tags":[],"yoast_head":"\n40 Useful Excel Macro [VBA] examples - Part 2 of 2 [ FREE DOWNLOAD ]<\/title>\n<meta name=\"description\" content=\"Top 40 useful Excel VBA code for Beginners. Download 40 Most frequently used Excel VBA examples for FREE. Excel macro tutorials for beginners. 40 most used Excel Macro examples for Excel VBA beginners. 40 Excel VBA examples to improve your productivity at work, Download Top 40 most useful Excel Macro examples for FREE\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"40 Useful Excel Macro [VBA] examples - Part 2 of 2 [ FREE DOWNLOAD ]\" \/>\n<meta property=\"og:description\" content=\"Top 40 useful Excel VBA code for Beginners. Download 40 Most frequently used Excel VBA examples for FREE. Excel macro tutorials for beginners. 40 most used Excel Macro examples for Excel VBA beginners. 40 Excel VBA examples to improve your productivity at work, Download Top 40 most useful Excel Macro examples for FREE\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Let's excel in Excel\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:author\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:published_time\" content=\"2018-06-28T21:44:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-17T19:17:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2018\/06\/40-useful-vba-codes.png\" \/>\n\t<meta property=\"og:image:width\" content=\"400\" \/>\n\t<meta property=\"og:image:height\" content=\"250\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Vishwamitra Mishra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/www.twitter.com\/learnexcelmacro\" \/>\n<meta name=\"twitter:site\" content=\"@learnexcelmacro\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vishwamitra Mishra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/\"},\"author\":{\"name\":\"Vishwamitra Mishra\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"headline\":\"40 Useful Excel Macro [VBA] examples – Part 2 of 2 [ FREE DOWNLOAD ]\",\"datePublished\":\"2018-06-28T21:44:10+00:00\",\"dateModified\":\"2022-08-17T19:17:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/\"},\"wordCount\":941,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"articleSection\":[\"Excel Macro\",\"Excel Macro Beginner\",\"Excel Macro Tutorial\",\"Popular Articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/\",\"name\":\"40 Useful Excel Macro [VBA] examples - Part 2 of 2 [ FREE DOWNLOAD ]\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\"},\"datePublished\":\"2018-06-28T21:44:10+00:00\",\"dateModified\":\"2022-08-17T19:17:00+00:00\",\"description\":\"Top 40 useful Excel VBA code for Beginners. Download 40 Most frequently used Excel VBA examples for FREE. Excel macro tutorials for beginners. 40 most used Excel Macro examples for Excel VBA beginners. 40 Excel VBA examples to improve your productivity at work, Download Top 40 most useful Excel Macro examples for FREE\",\"breadcrumb\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/vmlogger.com\/excel\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Excel Macro\",\"item\":\"https:\/\/vmlogger.com\/excel\/macro\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"40 Useful Excel Macro [VBA] examples – Part 2 of 2 [ FREE DOWNLOAD ]\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\",\"url\":\"https:\/\/vmlogger.com\/excel\/\",\"name\":\"Let's excel in Excel\",\"description\":\"Let's share knowledge\",\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/vmlogger.com\/excel\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\",\"name\":\"Vishwamitra Mishra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"contentUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"width\":528,\"height\":560,\"caption\":\"Vishwamitra Mishra\"},\"logo\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\"},\"description\":\"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore & currently working as a Technical Lead having over 7 years of experience.\",\"sameAs\":[\"http:\/\/www.learnexcelmacro.com\",\"http:\/\/www.facebook.com\/vmlogger\",\"https:\/\/twitter.com\/https:\/\/www.twitter.com\/learnexcelmacro\",\"https:\/\/www.youtube.com\/c\/VMLogger\"],\"url\":\"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"40 Useful Excel Macro [VBA] examples - Part 2 of 2 [ FREE DOWNLOAD ]","description":"Top 40 useful Excel VBA code for Beginners. Download 40 Most frequently used Excel VBA examples for FREE. Excel macro tutorials for beginners. 40 most used Excel Macro examples for Excel VBA beginners. 40 Excel VBA examples to improve your productivity at work, Download Top 40 most useful Excel Macro examples for FREE","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/","og_locale":"en_US","og_type":"article","og_title":"40 Useful Excel Macro [VBA] examples - Part 2 of 2 [ FREE DOWNLOAD ]","og_description":"Top 40 useful Excel VBA code for Beginners. Download 40 Most frequently used Excel VBA examples for FREE. Excel macro tutorials for beginners. 40 most used Excel Macro examples for Excel VBA beginners. 40 Excel VBA examples to improve your productivity at work, Download Top 40 most useful Excel Macro examples for FREE","og_url":"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/","og_site_name":"Let's excel in Excel","article_publisher":"http:\/\/www.facebook.com\/vmlogger","article_author":"http:\/\/www.facebook.com\/vmlogger","article_published_time":"2018-06-28T21:44:10+00:00","article_modified_time":"2022-08-17T19:17:00+00:00","og_image":[{"width":400,"height":250,"url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2018\/06\/40-useful-vba-codes.png","type":"image\/png"}],"author":"Vishwamitra Mishra","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/www.twitter.com\/learnexcelmacro","twitter_site":"@learnexcelmacro","twitter_misc":{"Written by":"Vishwamitra Mishra","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/#article","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/"},"author":{"name":"Vishwamitra Mishra","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"headline":"40 Useful Excel Macro [VBA] examples – Part 2 of 2 [ FREE DOWNLOAD ]","datePublished":"2018-06-28T21:44:10+00:00","dateModified":"2022-08-17T19:17:00+00:00","mainEntityOfPage":{"@id":"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/"},"wordCount":941,"commentCount":4,"publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"articleSection":["Excel Macro","Excel Macro Beginner","Excel Macro Tutorial","Popular Articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/","url":"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/","name":"40 Useful Excel Macro [VBA] examples - Part 2 of 2 [ FREE DOWNLOAD ]","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/#website"},"datePublished":"2018-06-28T21:44:10+00:00","dateModified":"2022-08-17T19:17:00+00:00","description":"Top 40 useful Excel VBA code for Beginners. Download 40 Most frequently used Excel VBA examples for FREE. Excel macro tutorials for beginners. 40 most used Excel Macro examples for Excel VBA beginners. 40 Excel VBA examples to improve your productivity at work, Download Top 40 most useful Excel Macro examples for FREE","breadcrumb":{"@id":"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/vmlogger.com\/excel\/2018\/06\/40-useful-excel-macro-examples-for-beginners-part-2-of-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vmlogger.com\/excel\/"},{"@type":"ListItem","position":2,"name":"Excel Macro","item":"https:\/\/vmlogger.com\/excel\/macro\/"},{"@type":"ListItem","position":3,"name":"40 Useful Excel Macro [VBA] examples – Part 2 of 2 [ FREE DOWNLOAD ]"}]},{"@type":"WebSite","@id":"https:\/\/vmlogger.com\/excel\/#website","url":"https:\/\/vmlogger.com\/excel\/","name":"Let's excel in Excel","description":"Let's share knowledge","publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vmlogger.com\/excel\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5","name":"Vishwamitra Mishra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/","url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","contentUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","width":528,"height":560,"caption":"Vishwamitra Mishra"},"logo":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/"},"description":"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore & currently working as a Technical Lead having over 7 years of experience.","sameAs":["http:\/\/www.learnexcelmacro.com","http:\/\/www.facebook.com\/vmlogger","https:\/\/twitter.com\/https:\/\/www.twitter.com\/learnexcelmacro","https:\/\/www.youtube.com\/c\/VMLogger"],"url":"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/"}]}},"_links":{"self":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/14834"}],"collection":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/users\/45"}],"replies":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/comments?post=14834"}],"version-history":[{"count":0,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/14834\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/media\/242874"}],"wp:attachment":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/media?parent=14834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/categories?post=14834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/tags?post=14834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}