简体   繁体   English

自动执行Excel任务的最简单方法是什么

[英]What is the easiest way to automate Excel tasks

If I need to automate a series a task on an excel sheet like 如果我需要自动执行一系列任务,可以在excel表上执行一项任务,例如

  • remove all rows where column 3 contains value "asdf" 删除列3包含值“ asdf”的所有行

  • remove column 7 and column 9 删除第7列和第9列

  • sort according to column 4 根据第4列排序

etc. 等等

What is the easiest way of automating such tasks in excel? 在excel中自动执行此类任务的最简单方法是什么? I think it would recording a macro but sometimes macro have to be edited a lot to actually make them work and even then macros stop if the excel sheet has a variation. 我认为它会记录一个宏,但有时必须对其进行大量编辑才能真正使它们工作,并且即使Excel工作表有变化,宏也会停止。 Editing macro scripts could be a time taking process which becomes inefficient for such tasks. 编辑宏脚本可能是一个耗时的过程,对于这些任务而言效率很低。 The automation is required since number of excel sheets will be a lot. 由于excel工作表数量很多,因此需要自动化。 Can you suggest an easier way ? 您能建议一种更简单的方法吗?

As long as, you have the activities defined - Macro is still the better thing to look for. 只要您定义了活动,宏仍然是更好的选择。
There could be some things that could change. 可能有些事情可能会改变。

Please explain the problem with the help of code. 请借助代码说明问题。
If you have defined the steps with a few variables, it should be easy to write a macro that wouldn't stop in case of variation. 如果您使用几个变量定义了步骤,那么编写一个在发生变化时不会停止的宏应该很容易。

Please post the code and describe in detail what you would want? 请发布代码并详细描述您想要什么? which point does it stop, in case of variation? 如果发生变化,它将停止在哪一点? What would you like the code to do? 您想要代码做什么?

EDIT: Alternatively, you can write code in VB6/.net (c#/vb.net)/Python for automation. 编辑:或者,您可以在VB6 / .net(c#/ vb.net)/ Python中编写代码以实现自动化。

If you record these steps using the macro recorder it will work fine, these are the ideal types of things for the macro recorder as the parameters (ie your sort by and delete conditions) are always the same. 如果使用宏记录器记录这些步骤,它将很好地工作,这是宏记录器的理想类型,因为参数(即,排序依据和删除条件)始终相同。 Just make sure that you always import/paste the data to the same place! 只要确保您始终将数据导入/粘贴到同一位置即可! Thanks Ross 谢谢罗斯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM