<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 如何在 Excel 中編寫宏:分步入門指南 > 原文: [https://www.guru99.com/introduction-to-macros-in-excel.html](https://www.guru99.com/introduction-to-macros-in-excel.html) ## 什么是 Excel 宏? **EXCEL MACRO** 是一種記錄和播放工具,它僅記錄您的 Excel 步驟,并且宏將根據需要播放任意多次。 VBA 宏可自動執行重復任務,從而節省了時間。 這是一段可在 Excel 環境中運行的編程代碼,但您無需成為編碼器即可對宏進行編程。 但是,您需要 VBA 的基礎知識才能在宏中進行高級修改。 在本教程中,您將學習 * [為什么在 Excel 中使用 Excel 宏?](#2) * [外行人使用的 VBA 是什么?](#3) * [宏基礎知識](#4) * [在 Excel 中記錄宏的分步示例](#5) ## 為什么在 Excel 中使用 Excel 宏? 作為人類,我們是習慣的產物。 我們每天每個工作日都會做某些事情。 如果有某種神奇的方法可以按一個按鈕并且完成了我們所有的例行任務,這會更好嗎? 我能聽到你說是的。 宏可以幫助您實現這一目標。 用外行語言來說,宏定義為您在 Excel 中的常規步驟的記錄,您可以使用單個按鈕進行重放。 例如,您正在作為自來水公司的出納員。 一些客戶通過銀行付款,最終,您需要從銀行下載數據并以符合業務需求的方式對其進行格式化。 您可以將數據導入 Excel 和格式。 第二天,您將需要執行相同的儀式。 它將很快變得無聊和乏味。 **宏通過自動執行此類常規任務**解決了此類問題。 您可以使用宏來記錄以下步驟 * 導入數據 * 對其進行格式化以滿足您的業務報告要求。 ## 外行語言的 VBA 是什么? **VBA 是 Visual Basic for Applications 的縮寫。** 這是一種編程語言,Excel 在執行日常任務時會使用它來記錄您的步驟。 您無需成為程序員或技術人員就可以享受 Excel 中宏的好處。 Excel 具有自動為您生成源代碼的功能。 閱讀有關 Vba 的文章以了解更多詳細信息。 ## 宏基礎知識 **宏是開發人員功能之一。 默認情況下,開發人員選項卡不顯示在 excel 中。 您需要通過自定義報告**顯示它 攻擊者可以使用宏來破壞您的系統。 默認情況下,它們在 excel 中被禁用。 如果需要運行宏,則將需要啟用運行宏,并且僅運行您知道來自受信任來源的宏 如果要保存宏,則必須將工作簿保存為啟用宏的格式* .xlsm 宏名稱不得包含任何空格。 創建宏時,請務必填寫宏的描述。 這將幫助您和其他人了解宏在做什么。 ## 在 Excel 中記錄宏的分步示例 我們將使用宏 excel 重要性中描述的方案進行工作。 我們將使用以下 CSV 文件。 ![Introduction to Macros in Excel](https://img.kancloud.cn/cd/d7/cdd70f55684820d8e5d2951539d063a9_280x121.png "Introduction to Macros in Excel") 您可以在此處下載以上文件 [下載上述 CSV 文件&宏](https://drive.google.com/uc?export=download&id=0BwL5un1OyjsdcEl4Y1N6SGZkWWs) 我們將創建一個啟用宏的模板,該模板將導入上述數據并對其進行格式化,以滿足我們的業務報告要求。 **## 啟用開發者選項** 要執行 VBA 程序,您必須有權訪問 Excel 中的開發人員選項。 如下所示啟用開發人員選項,然后將其固定到 Excel 中的主要功能區。 **步驟 1)**轉到主菜單“文件” 選擇選項“選項”。 ![How to Write Macros in Excel](https://img.kancloud.cn/a4/4e/a44ebfc91f46223ec6664ad43480741b_259x243.png) [![What is VBA?](https://img.kancloud.cn/15/17/15177b4f7d971f75306b818f0114f911_450x516.png "What is VBA?") ](/images/vba/062416_1048_WhatisVBA2.png) **步驟 2)**現在將打開另一個窗口,在該窗口中執行以下操作 * 單擊自定義功能區 * 將復選框標記為開發人員選項 * 點擊確定按鈕 ![How to Write Macros in Excel](https://img.kancloud.cn/5b/67/5b6769d3010eaaab1bf69f7930847820_730x415.png) **步驟 3)**開發人員標簽 現在,您將能夠在功能區中看到“開發人員”選項卡 ![How to Write Macros in Excel](https://img.kancloud.cn/94/34/9434423b9a6a08ed6494d9aefbb8ca05_1096x184.png) **步驟 4)**下載 CSV 首先,我們將看到如何在電子表格上創建命令按鈕并執行程序。 * 在驅動器 C 中創建一個名為 Bank Receipts 的文件夾 * 粘貼您下載的 receives.csv 文件 ![How to Write Macros in Excel](https://img.kancloud.cn/a3/31/a331eb1567afaeaea9731175c0710877_701x243.png) **步驟 5)**記錄宏 1. 單擊開發人員選項卡 2. 單擊記錄宏,如下圖所示 ![How to Write Macros in Excel](https://img.kancloud.cn/77/ab/77ab69e0d063ce2a73e768e26decb2a9_870x269.png) 您將獲得以下對話窗口 ![Introduction to Macros in Excel](https://img.kancloud.cn/30/f6/30f64f5abf38ddec15ca2a068029eff6_358x295.png "Introduction to Macros in Excel") 1. 輸入 ImportBankReceipts 作為宏名稱。 2. 第二步將默認存在 3. 輸入說明,如上圖所示 4. 點擊“確定”標簽 **步驟 6)**執行您要記錄的宏操作/步驟 * 將光標放在單元格 A1 中 * 單擊數據選項卡 * 單擊“獲取外部數據”功能區欄上的“來自文本”按鈕 You will get the following dialogue window ![How to Write Macros in Excel](https://img.kancloud.cn/30/1e/301e9344634024e5d58e1c54961ea8f1_658x366.png) 1. 轉到存儲 CSV 文件的本地驅動器 2. 選擇 CSV 文件 3. 點擊導入按鈕 您將獲得以下向導 ![Introduction to Macros in Excel](https://img.kancloud.cn/5c/ec/5cecdf5f4e3f88d12b1aef36d3254c22_589x445.png "Introduction to Macros in Excel") 完成上述步驟后,單擊“下一步”按鈕 ![Introduction to Macros in Excel](https://img.kancloud.cn/f6/90/f6902f91c7c8f08dc026f2b5533d1d5c_589x445.png "Introduction to Macros in Excel") 請按照上述步驟操作,然后單擊下一步按鈕 ![Introduction to Macros in Excel](https://img.kancloud.cn/26/11/2611a022045ce187f72496b87af15cfe_589x445.png "Introduction to Macros in Excel") * 點擊完成按鈕 * 您的工作簿現在應如下所示 [![Introduction to Macros in Excel](https://img.kancloud.cn/b7/57/b75711509cffd1051072d3e1dc61600f_389x253.png "Introduction to Macros in Excel") ](/images/5-2015/050215_1033_Introductio10.png) **步驟 7)**格式化數據 將列設為粗體,添加總計,然后使用 SUM 函數獲取總計。 ![How to Write Macros in Excel](https://img.kancloud.cn/67/81/67813473e13d6287e2a7ce0d496513f4_393x266.png) **步驟 8)**停止錄制宏 現在我們已經完成了日常工作,我們可以單擊停止錄制宏按鈕,如下圖所示 ![How to Write Macros in Excel](https://img.kancloud.cn/fb/51/fb5179751056a823cc680973892e4f42_754x205.png) **步驟 9)**重播宏 在保存工作簿之前,我們將需要刪除導入的數據。 我們將執行此操作以創建一個模板,該模板將在每次我們有新的收據并要運行 ImportBankReceipts 宏時復制。 * 突出顯示所有導入的數據 * 右鍵單擊突出顯示的數據 * 點擊刪除 * 單擊另存為按鈕 * 將工作簿保存為啟用宏的格式,如下所示 ![How to Write Macros in Excel](https://img.kancloud.cn/55/66/556675953986c176acceed87eedb8f24_634x484.png) * 復制新保存的模板 * 打開它 * 單擊開發人員選項卡 * 單擊宏按鈕 You will get the following dialogue window ![Introduction to Macros in Excel](https://img.kancloud.cn/a7/0c/a70c23ac49837327e442f8ef8f5286a3_390x370.png "Introduction to Macros in Excel") 1. 選擇 ImportBankReceipts 2. 突出顯示您的宏的描述 3. 點擊運行按鈕 您將獲得以下數據 ![Introduction to Macros in Excel](https://img.kancloud.cn/67/81/67813473e13d6287e2a7ce0d496513f4_393x266.png "Introduction to Macros in Excel") 恭喜,您剛剛在 excel 中創建了第一個宏。 ## 摘要 宏通過使我們執行的大多數日常工作自動化來簡化我們的工作生活。 Excel 中的宏由 Visual Basic for Applications 驅動。 To execute VBA program, you have to have access to developer option in Excel. Enable the developer option as shown below and pin it into your main ribbon in Excel. **Step 1)**Go to main menu "FILE" Select option "Options." ![How to Write Macros in Excel](https://img.kancloud.cn/a4/4e/a44ebfc91f46223ec6664ad43480741b_259x243.png) ![What is VBA?](https://img.kancloud.cn/15/17/15177b4f7d971f75306b818f0114f911_450x516.png "What is VBA?") **Step 1)**Go to main menu "FILE" Select option "Options." **Step 2)** Now another window will open, in that window do following things * 單擊自定義功能區 * 將復選框標記為開發人員選項 * 點擊確定按鈕 ![How to Write Macros in Excel](https://img.kancloud.cn/5b/67/5b6769d3010eaaab1bf69f7930847820_730x415.png) **Step 2)** Now another window will open, in that window do following things * 單擊自定義功能區 * 將復選框標記為開發人員選項 * 點擊確定按鈕 **Step 3)** Developer Tab You will now be able to see the DEVELOPER tab in the ribbon ![How to Write Macros in Excel](https://img.kancloud.cn/94/34/9434423b9a6a08ed6494d9aefbb8ca05_1096x184.png) **Step 3)** Developer Tab You will now be able to see the DEVELOPER tab in the ribbon **Step 4)** Download CSV First, we will see how we can create a command button on the spreadsheet and execute the program. * 在驅動器 C 中創建一個名為 Bank Receipts 的文件夾 * 粘貼您下載的 receives.csv 文件 ![How to Write Macros in Excel](https://img.kancloud.cn/a3/31/a331eb1567afaeaea9731175c0710877_701x243.png) **Step 4)** Download CSV First, we will see how we can create a command button on the spreadsheet and execute the program. **Step 5)** Record Macro 1. 單擊開發人員選項卡 2. 單擊記錄宏,如下圖所示 ![How to Write Macros in Excel](https://img.kancloud.cn/77/ab/77ab69e0d063ce2a73e768e26decb2a9_870x269.png) You will get the following dialogue window ![Introduction to Macros in Excel](https://img.kancloud.cn/30/f6/30f64f5abf38ddec15ca2a068029eff6_358x295.png "Introduction to Macros in Excel") 1. 輸入 ImportBankReceipts 作為宏名稱。 2. 第二步將默認存在 3. 輸入說明,如上圖所示 4. 點擊“確定”標簽 **Step 5)** Record Macro 1. 單擊開發人員選項卡 2. 單擊記錄宏,如下圖所示 **Step 6)** Perform Macro Operations/Steps you want to record * 將光標放在單元格 A1 中 * 單擊數據選項卡 * 單擊“獲取外部數據”功能區欄上的“來自文本”按鈕 You will get the following dialogue window ![How to Write Macros in Excel](https://img.kancloud.cn/30/1e/301e9344634024e5d58e1c54961ea8f1_658x366.png) 1. 轉到存儲 CSV 文件的本地驅動器 2. 選擇 CSV 文件 3. 點擊導入按鈕 You will get the following wizard ![Introduction to Macros in Excel](https://img.kancloud.cn/5c/ec/5cecdf5f4e3f88d12b1aef36d3254c22_589x445.png "Introduction to Macros in Excel") Click on Next button after following the above steps ![Introduction to Macros in Excel](https://img.kancloud.cn/f6/90/f6902f91c7c8f08dc026f2b5533d1d5c_589x445.png "Introduction to Macros in Excel") Follow the above steps and click on next button ![Introduction to Macros in Excel](https://img.kancloud.cn/26/11/2611a022045ce187f72496b87af15cfe_589x445.png "Introduction to Macros in Excel") * 點擊完成按鈕 * 您的工作簿現在應如下所示 ![Introduction to Macros in Excel](https://img.kancloud.cn/b7/57/b75711509cffd1051072d3e1dc61600f_389x253.png "Introduction to Macros in Excel") **Step 6)** Perform Macro Operations/Steps you want to record * 將光標放在單元格 A1 中 * 單擊數據選項卡 * 單擊“獲取外部數據”功能區欄上的“來自文本”按鈕 **Step 7)** Format the Data Make the columns bold, add the grand total and use the SUM function to get the total amount. ![How to Write Macros in Excel](https://img.kancloud.cn/67/81/67813473e13d6287e2a7ce0d496513f4_393x266.png) **Step 7)** Format the Data Make the columns bold, add the grand total and use the SUM function to get the total amount. **Step 8)** Stop Recording Macro Now that we have finished our routine work, we can click on stop recording macro button as shown in the image below ![How to Write Macros in Excel](https://img.kancloud.cn/fb/51/fb5179751056a823cc680973892e4f42_754x205.png) **Step 8)** Stop Recording Macro Now that we have finished our routine work, we can click on stop recording macro button as shown in the image below **Step 9)** Replay the Macro Before we save our work book, we will need to delete the imported data. We will do this to create a template that we will be copying every time we have new receipts and want to run the ImportBankReceipts macro. * 突出顯示所有導入的數據 * 右鍵單擊突出顯示的數據 * 點擊刪除 * 單擊另存為按鈕 * 將工作簿保存為啟用宏的格式,如下所示 ![How to Write Macros in Excel](https://img.kancloud.cn/55/66/556675953986c176acceed87eedb8f24_634x484.png) * 復制新保存的模板 * 打開它 * 單擊開發人員選項卡 * 單擊宏按鈕 You will get the following dialogue window ![Introduction to Macros in Excel](https://img.kancloud.cn/a7/0c/a70c23ac49837327e442f8ef8f5286a3_390x370.png "Introduction to Macros in Excel") 1. 選擇 ImportBankReceipts 2. 突出顯示您的宏的描述 3. 點擊運行按鈕 You will get the following data ![Introduction to Macros in Excel](https://img.kancloud.cn/67/81/67813473e13d6287e2a7ce0d496513f4_393x266.png "Introduction to Macros in Excel") Congratulations, you just created your first macro in excel. **Step 9)** Replay the Macro Before we save our work book, we will need to delete the imported data. We will do this to create a template that we will be copying every time we have new receipts and want to run the ImportBankReceipts macro.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看