谷歌表格_如何使用宏自動執行Google表格

谷歌表格

谷歌表格

Google Sheets lets you automate repetitive tasks with macros, and you can then bind them to keyboard shortcuts to execute them quickly. They work using Google Apps Script to capture your actions for later use.

Google表格可以讓您使用宏自動執行重復性任務,然后可以將其綁定到鍵盤快捷鍵以快速執行它們。 他們使用Google Apps腳本來捕獲您的操作以供以后使用。

什么是宏? (What are Macros?)

A macro—or macroinstruction—is a specific sequence of actions that let you automate a series of steps to increase productivity. They work by recording your actions and saving them into a file that’s bound to the spreadsheet in which they were recorded.

宏(或宏指令)是特定的操作序列,可讓您自動化一系列步驟以提高生產率。 它們的工作方式是記錄您的操作并將其保存到與記錄了這些操作的電子表格綁定的文件中。

When you record a macro in Google Sheets, it automatically creates an Apps Script?with all the code to replicate your actions for you. This means you can create complex macros without knowing how to write code. The next time you run it, Sheets will do everything you did when you recorded the macro. Essentially, you’re teaching Google Sheets how to manipulate a document to your liking with a single command.

當您在Google表格中記錄宏時,它會自動創建一個包含所有代碼的Apps腳本,以為您復制操作。 這意味著您可以在不知道如何編寫代碼的情況下創建復雜的宏。 下次運行它時,Sheets將完成您在錄制宏時所做的所有操作。 本質上,您是在教Google表格如何通過單個命令來按自己的喜好操縱文檔。

Macros are a powerful feature that can do basically anything Sheets is capable of doing. Here are just a few examples of its functionality:

宏是一項強大的功能,基本上可以完成Sheets能夠執行的任何操作。 以下是其功能的一些示例:

  • Apply formatting and styles.

    應用格式和樣式。
  • Create completely new spreadsheets.

    創建全新的電子表格。
  • Use any Google Sheets function, toolbar, menu, or feature.

    使用任何Google表格功能,工具欄,菜單或功能。

The sky is the limit.

天空才是極限。

如何在Google表格中記錄宏 (How to Record a Macro in Google Sheets)

Fire up a Google Sheet and click Tools > Macros > Record Macro.

啟動Google表格,然后單擊工具>宏>記錄宏。

Click Tools > Macros > Record Macro

This opens the recording menu at the bottom of the window, with two options for capturing your actions:

這將打開窗口底部的“錄制”菜單,其中有兩個用于捕獲動作的選項:

  • Absolute References:?The macro will do tasks only on the exact cells you record. If you italicize cell B1, the macro will only ever italicize B1 regardless of what cell you clicked on.

    絕對引用:宏將僅在您記錄的確切單元格上執行任務。 如果您將單元格B1變為斜體,則無論您單擊哪個單元格,宏都只會將其斜體為B1。

  • Relative References:??The macro will do tasks on the selected cells, regardless of where they are in the sheet. If you italicize B1 and C1, you can re-use the same macro to italicize cells D1 and E1 later.

    相關參考:宏將在選定的單元格上執行任務,無論它們在表中的位置如何。 如果將B1和C1斜體化,則可以在以后重新使用同一宏來斜體化單元格D1和E1。

Select whether you want an absolute or relative reference, then you can start to click, format, and teach Sheets what order you want these actions to replicate.

選擇您要的是絕對參考還是相對參考,然后可以單擊,格式化和教導Sheets您希望這些操作復制的順序。

Choose either Absolute References or Relative References

After you’ve captured all the actions for this macro, click “Save.”

在捕獲了該宏的所有動作之后,單擊“保存”。

Click Save when you're done recording

Enter a name for your macro.?Google also lets you create shortcuts for up to?ten?macros. If?you want to bind a macro to a keyboard shortcut, enter a number from 0-9 in the space provided. When you finish, click “Save.”

輸入宏的名稱。 Google還允許您創建最多?十個宏如果要將宏綁定到鍵盤快捷鍵,請在提供的空格中輸入0-9之間的數字。 完成后,單擊“保存”。

Enter a name for your macro, then click Save

If you need to tweak your macro’s name or shortcut, you can edit a macro by clicking Tools > Macros > Manage Macros.

如果需要調整宏的名稱或快捷方式,可以通過單擊工具>宏>管理宏來編輯宏。

To create a keyboard shortcut, click Tools > Macros > Manage Macros

From the window that opens, tweak as desired and then click “Update.”

在打開的窗口中,根據需要進行調整,然后單擊“更新”。

Beside each macro, enter a number from 0-9 to bind to a shortcut

The next time you press the shortcut associated with the macro, it will run without having to open the macro menu from the toolbar.

下次您按下與宏關聯的快捷方式時,它將運行,而無需從工具欄打開宏菜單。

如何在Google表格中運行宏 (How to Run a Macro in Google Sheets)

If your macro is an absolute reference, you can run the macro by pressing the keyboard shortcut or go to?Tools > Macros > Your Macro and then click the appropriate option.

如果您的宏是絕對引用,則可以通過按鍵盤快捷鍵或轉到“工具”>“宏”>“您的宏”,然后單擊適當的選項來運行宏。

Click Tools > Macros > YourMacroName to run your macro

Otherwise, if your macro is a relative reference, highlight the cells in your spreadsheet on which you want the macro to run and then press the corresponding shortcut, or click on it from Tools > Macros > Your Macro.

否則,如果您的宏是相對引用,請突出顯示電子表格中您要在其上運行宏的單元格,然后按相應的快捷方式,或者從“工具”>“宏”>“您的宏”中單擊它。

If you made a relative referenced macro, highlight the cells, then click Tools > Macros > YourMacroName, to run the macro

如何導入宏 (How to Import Macros)

As mentioned earlier, when you record a macro, it gets bound to the spreadsheet on which you recorded it. But what if you want to import a macro from another spreadsheet??While it’s not a straightforward and simple task, you can do it using this little workaround.

如前所述,當您記錄宏時,它會綁定到記錄宏的電子表格。 但是,如果要從另一個電子表格導入宏該怎么辦? 盡管這不是一項簡單明了的任務,但是您可以使用此小解決方法來完成。

Because recorded macros are stored as functions in Google Apps Script, to import a macro, you need to copy the function and then paste it in the new sheet’s macro file.

由于錄制的宏是作為函數存儲在Google Apps腳本中的,因此要導入宏,您需要復制該函數,然后將其粘貼到新工作表的宏文件中。

Open the Google Sheet with the macro you want to copy and then click on Tools > Macros > Manage Macros.

使用您要復制的宏打開Goog??le表格,然后單擊工具>宏>管理宏。

Click on Tools > Macros > Manage Macros

Next, click the “More” icon next to the macro you’d like to copy and then click “Edit Script.”

接下來,點擊您要復制的宏旁邊的“更多”圖標,然后點擊“編輯腳本”。

Click the more icon, then click Edit Script

All macros save to the same file, so if you have a couple of macros saved, you may have to sift through them.?The function’s name is the same one you gave it when you created it.

所有宏都保存到同一個文件中,因此,如果您保存了幾個宏,則可能必須在它們之間進行篩選。 該函數的名稱與您創建函數時使用的名稱相同。

Highlight the macro(s) you want to copy, then press Ctrl + C.?Be sure to copy everything up to and including the closing semi-colon.

突出顯示要復制的宏,然后按Ctrl +C。確保將所有內容復制到包括分號在內的所有內容。

Highlight and copy the macro's function with Ctrl + C

Now, open the other spreadsheet you’ll be importing the macro to and click Tools > Macros > Record Macro.

現在,打開要將宏導入到的其他電子表格,然后單擊工具>宏>記錄宏。

Create a new macro in your other spreadsheet. Click Tools > Macros > Record Macro

Immediately click “Save” without recording any actions to create a placeholder function in the sheet’s macro file for us. You’ll be deleting this a little later.

立即單擊“保存”,而無需進行任何操作即可在工作表的宏文件中為我們創建占位符功能。 您稍后會刪除它。

Click Save

Click “Save” again.

再次單擊“保存”。

You don't need to worry about naming it, click Save

Open Google Apps Script by clicking Tools > Script Editor, and then open the macros.gs file from the left pane. Delete the existing function and then press Ctrl + V to paste in the macro from your other Sheet.

通過單擊工具>腳本編輯器,打開Goog??le Apps腳本,然后從左窗格中打開macros.gs文件。 刪除現有功能,然后按Ctrl + V從其他工作表粘貼到宏中。

In the macros.gs file, paste the macro's function from the first spreadsheet

Press Ctrl + S to save the script, close the tab, and return to your spreadsheet.

按Ctrl + S保存腳本,關閉選項卡,然后返回到電子表格。

Your spreadsheet reads the macros.gs file and looks for changes made to it. If a new function is detected, you can use the Import feature to add a macro from another sheet.

您的電子表格將讀取macros.gs文件并查找對其所做的更改。 如果檢測到新功能,則可以使用“導入”功能從另一個工作表添加宏。

Next, click Tools > Macros > Import.

接下來,單擊工具>宏>導入。

Click Tools > Macros > Import to import the macros to this document

Finally, click “Add Function” under the macro you want to add.

最后,在要添加的宏下單擊“添加功能”。

Finally, click Add Function next to the macro you want to add

Unfortunately, you will have to bind the macro manually to a keyboard shortcut again. Just follow the instruction previously mentioned, and you’ll be all set to use this macro across multiple sheets.

不幸的是,您將不得不再次將宏手動綁定到鍵盤快捷鍵。 只要按照前面提到的說明進行操作,就可以在多個工作表上使用此宏。



That’s all there is to creating and using macros in Google Sheets. There’s no limit to the routines you can create for your spreadsheets to limit the amount of time you spend doing these repetitive tasks.

這就是在Google表格中創建和使用宏的全部內容。 您可以為電子表格創建的例程沒有限制,以限制您花費在執行這些重復任務上的時間。

翻譯自: https://www.howtogeek.com/413334/how-to-automate-google-sheets-with-macros/

谷歌表格

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/278970.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/278970.shtml
英文地址,請注明出處:http://en.pswp.cn/news/278970.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

阿里云彈性高性能計算E-HPC強勢來襲,全新打造一站式云超算

為什么80%的碼農都做不了架構師?>>> 摘要: 如今,高性能計算已在不知不覺中滲透到人類生活的方方面面。從材料科學到石油勘探、金融市場、應急管理、醫學和互聯網等領域,高性能計算無一不大顯身手,幫助快速…

linux導出硬件信息,Linux 上生成硬件信息與配置報告: Sysreport

當需要 Linux 主機詳細完整的描述給另一個人的時候,這個工具非常適合。用 root 用戶之行,但要注意最好不要抓取 currently installed packages 信息,這一步非常慢。(用 -norpm 參數)存儲廠商 EMC 也有個 EMCgrab 工具,工作原理類似…

深度優先搜索(DFS)----------------Tju_Oj_3517The longest athletic track

這個題主要考察對樹的操作,主要思想是DFS或者BFS,其次是找樹的直徑方法(既要運用兩次BFS/DFS),最后作為小白,還練習了vector的操作。 DFS框架偽碼: bool DSF(Node oneTreePoint ){ //傳入的結點和其他有效…

word中圖片超出頁邊距_如何在Word中更改頁邊距

word中圖片超出頁邊距Word documents open with one-inch margins by default. You can adjust the page margins by choosing one of Word’s predefined options, or you can specify the exact height and width of the margins yourself. Here’s how. 默認情況下&#xff…

Android 中文 API (16) —— AnalogClock

一、結構 public class AnalogClock extends View java.lang.Object android.view.View android.widget.AnalogClock 二、類概述 這是一個帶有時針和分針的模擬時鐘控件。 三、受保護的方法 protected void onAttachedToWindow () 視圖(AnalogClock)附在…

linux服務器探針軟件,服務器安裝ServerStatus監控探針教程

前言本文將介紹在服務器上安裝ServerStatus來監控多臺服務器的運行狀態的教程.ServerStatus-Toyo版是一個酷炫高逼格的云探針、云監控、服務器云監控、多服務器探針~,該云監控(云探針)ServerStatus-Toyo項目鏈接本文為Stille原創文章.經實踐,測試,整理發布.如需轉載…

iphone播客怎么上傳_如何在iPhone,iPad或Android上收聽播客

iphone播客怎么上傳Khamosh PathakKhamosh PathakDid someone recently recommend you listen to a podcast? If your response was, “What’s a podcast?” we’ve got the answer, and more! Here’s a crash course on podcasts and how you can listen to them on your …

NOIP2018 退役記

NOIP掛完,OI再見 AFO Day 0 早上的高鐵,1點多到廣州,2點多到酒店,下午就是頹頹頹,然后晚上隨便刷了一下板子,反正PJ也沒啥板子可以刷 就這樣浪費了一天,我到底在干嘛 Day 1 早上心態很好的繼續刷…

Linux決心書/李世超

Linux決心書大家好,我叫李世超,來自河北邯鄲。今年24,感覺之前的生活狀態不是自己想要的,每天渾渾噩噩。我覺得人要對自己定一個目標,我的目標就是月薪10K以上,所以我要努力在老男孩教育學習技術。珍惜這五…

linux下設備或資源忙,linux刪除文件目錄 目錄設備或資源忙怎么辦

linux刪除文件目錄 目錄設備或資源忙怎么辦來源:未知作者:老黑時間:09-09-21【打印】[rootrs swms]# rmdir zpggrmdir: ‘zpgg’: 設備或資源忙相關服務都已經停止掉了,有什么辦法強制刪除嗎?你可以在有windows的硬盤上…

Codeforces 1066 C(思維)

傳送門: 題面: C. Books Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have got a shelf and want to put some books on it. You are given qq queries of three type…

outlook默認簽名設置_如何將默認簽名添加到Outlook會議請求

outlook默認簽名設置An odd quirk in Outlook is the inability to add a default signature to meeting requests. Here’s a quick and simple way to set up a one-click solution that avoids cutting and pasting every time you create a meeting. Outlook中的一個奇怪問…

技嘉 linux設置u盤啟動項,技嘉主板bios設置u盤啟動教程

對于想要重裝系統的朋友來說,進bios一直是最大的難關,對于技嘉主板來說尤為復雜,下面小編就詳細給大家介紹一下技嘉主板bios設置u盤啟動的方法。方法一:使用u盤啟動快捷鍵直接進入u盤裝系統1、技嘉主板u盤啟動快捷鍵是F12&#xf…

uefi模式下win10安裝雙系統ubuntu18.04LTS

自己折騰了半天,血與淚啊(難得一個可愛的周末 wwww我一定要寫下來 跟這個博客幾乎一模一樣了 https://blog.csdn.net/xrinosvip/article/details/80428133 我的電腦型號:戴爾G3 默認uefi模式,按f2進入的bios界面是新版跟教程上的不…

outlook日歷不顯示_如何在Outlook Online中突出顯示不同的日歷

outlook日歷不顯示If you’ve ever displayed multiple calendars in one view in Outlook Online, you’ll know how useful it is but also how confusing it can get. Use colors and charms to know at a glance which appointment belongs to which calendar. 如果您曾經在…

WinRAR 5.40 4.20 3.93 的注冊碼 - rarreg.key

把下面的數據復制到“記事本”中,用文件名“rarreg.key”命名該文件,保存到WinRAR安裝文件夾即完成注冊。以下4個Key隨便選一個復制都可以。WinRAR 5.40 版Key,復制箭頭中間內容,上下無空格。(5.00版的Key 4.X和之前的3.X版本也能…

linux 下eclipse調試程序,文章2 Linux安裝Eclipse閱讀及調試程序

由于安裝Eclipse需要Java環境,還需要配置環境,非常復雜,建議安裝系統時,選擇上Eclipse開發工具但是安裝的Eclipse中沒有CDT。首先給Eclipse安裝一個CDT。1.安裝CDTEclipse菜單欄help----Install New Software.從Available Softwar…

Redis學習筆記~分布式的Pub/Sub模式

redis的客戶端有很多,這次用它的pub/sub發布與訂閱我選擇了StackExchange.Redis,發布與訂閱大家應該很清楚了,首先一個訂閱者,訂閱一個服務,服務執行一些處理程序(可能是寫個日志,插入個數據&am…

django自定義用戶表

django自帶了用戶表。 -- auto-generated definition create table auth_user (id int auto_incrementprimary key,password varchar(128) not null,last_login datetime(6) null,is_superuser tinyint(1) not null,username varchar(150) not null,fir…

easyui關機圖標_如何在Windows 10中創建關機圖標

easyui關機圖標It’s true that shutting down your Windows 10 PC the old-fashioned way only takes three clicks. But why spend the extra energy when you can do it in two? All you have to do is create a shutdown icon, and you’ll save yourself some time. 的確…