谷歌表格_如何使用宏自动执行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.mzph.cn/news/278970.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

阿里云弹性高性能计算E-HPC强势来袭,全新打造一站式云超算

为什么80%的码农都做不了架构师?>>> 摘要: 如今,高性能计算已在不知不觉中渗透到人类生活的方方面面。从材料科学到石油勘探、金融市场、应急管理、医学和互联网等领域,高性能计算无一不大显身手,帮助快速…

深度优先搜索(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 早上心态很好的继续刷…

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…

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. 如果您曾经在…

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…

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. 的确…

Struts2+JFreeChart

下面以边帖图片和代码的方式来讲解Struts2与JFreeChart的整合。搭建环境:首先帖一张工程的目录结构以及所需的jar包。注意:如果你不打算自己写ChartResult的话只需要引入struts2-jfreechart-plugin-2.0.6.jar(这个在struts-2.0.6-all.zip可以找到了): …

linux c视频如何加水印,如何在Kdenlive的视频上进行水印 | MOS86

如果你这些东西被称为水印。他们So,你如何在Linux中创建水印?嗯,你这可能是Linux上最强大的开源视频编辑器。Installation如果您尚未安装Kdenlive,您应该可以在包裹管理器中找到它。在Ubuntu中,您还可以使用命令:sudo …

mac触控板手势无法使用_如何在iPad上使用触控板手势

mac触控板手势无法使用Apple苹果Apple’s new floating Magic Keyboard case for the iPad Pro looks fantastic, but you don’t need to spend $299 to use a trackpad. Simply connect a Magic Trackpad or a third-party multi-touch trackpad to get access to all of iPa…

安装SQLserver2008

双击点击setup,以管理员身份运行; 点击安装-》全新SQLServer独立安装或向现有安装添加功能 选择下一步,然后点击具有高级服务的express版本,点击下一步; 点击选择我接受许可条款,然后继续点击下一步&#x…

如何在没有Word的情况下打开Microsoft Word文档

Microsoft Word is part of Microsoft Office and requires an up-front purchase or a Microsoft 365 subscription. If you’re using a computer without Word installed, there are other ways to view that DOCX or DOC file. Microsoft Word是Microsoft Office的一部分&a…

数组去重的4种方法(Which one is the fastest???嘻嘻嘻....)

<!DOCTYPE html> <html lang"en"> <head> <meta charset"UTF-8"> <title>Document</title> </head> <body> <input type"button" value"数组去重1" οnclick"show()"&g…

windows复制文件路径_如何在Windows 10上复制文件的完整路径

windows复制文件路径Sometimes, it’s handy to copy the full path of a file or folder in Windows 10 to the clipboard. That way, you can paste the path into an open or upload dialog quickly without having to browse for it the file. Luckily, there’s an easy w…