简体   繁体   English

Excel文件和Visual Basic

[英]Excel Files and Visual Basic

I have never used Visual Basic before but could do with a pointer on where to begin. 我以前从未使用过Visual Basic,但可以使用从哪里开始的指针。

I have 750 excel spreadsheets that contains various amounts of data of different types. 我有750个excel电子表格,其中包含大量不同类型的数据。 The columns are always the same, but the number of data rows vary per spreadsheet. 列始终相同,但是每个电子表格的数据行数不同。 I need to extract data and put it into two new spreadsheets. 我需要提取数据并将其放入两个新的电子表格中。

Obviously to do this 750 times manually would be a nightmare. 显然,手动执行此操作750次将是一场噩梦。 I just want to run a script that can do it for me and thus thought of Visual Basic although i've never used it before. 我只想运行一个可以为我做的脚本,因此想起了Visual Basic,尽管我以前从未使用过它。

My specific questions are: 我的具体问题是:

  1. What type of command should i research that would allow me to copy data where the row number to start at varies (as data above varies in no of rows). 我应该研究哪种类型的命令,使我可以将数据复制到行号开头的地方不同(因为上面的数据没有行数)。 There is a title before this new data - how can i get it to search for this title and then choose the row below? 在此新数据之前有一个标题-如何获取它以搜索此标题,然后选择下面的行?
  2. Would all my spreadsheets have to be in one folder so that the script goes through them all, or can i have some kind of folder structure in that folder too? 我所有的电子表格都必须放在一个文件夹中,以便脚本可以全部通过它们吗?或者我也可以在该文件夹中使用某种文件夹结构吗?
  3. Anyone recommend any good resources for me to get to grips with visual basic and grasp what i need to do? 有人为我推荐任何好的资源来掌握视觉基础并掌握我需要做什么吗?

thanks 谢谢

Tom 汤姆

So the compilation task got easier with the introduction of MS PowerQuery. 因此,随着MS PowerQuery的引入,编译任务变得更加容易。 If you are using MS Excel 2013, you already have this. 如果您使用的是MS Excel 2013,则已经具有此功能。 If no, you should download it and use the extension from MS . 如果否, 则应下载它并使用MS的扩展名

The following guide outlines how to Using Power Query to Combine Data from Multiple Excel Files into One Table . 以下指南概述了如何使用Power Query将来自多个Excel文件的数据组合到一个表中 This means that with Power Query (PQ), MS has taken and enabled easy aggregation using a few simple button clicks. 这意味着,借助Power Query(PQ),MS只需单击几下即可进行并启用了轻松聚合。 PQ is a lightweight alternative to a lot of tasks that used to require VBA. PQ是许多以前需要VBA的任务的轻型替代方案。

In this example, you will use PQ to point to an entire folder (750 should be no problem) worth of commonly formatted Excel files. 在此示例中,您将使用PQ指向价值通常格式化的Excel文件的整个文件夹(应该没有问题750)。 The only limitation is that each data file should have a similarly named tab. 唯一的限制是每个数据文件都应具有类似命名的标签。

I won't repeat the details of the guide for how to do it, as it is in-depth and visual. 我不会重复该指南的细节,因为它是深入而直观的。 But if you run into issues, get in touch. 但是,如果遇到问题,请保持联系。

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

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