简体   繁体   English

在Excel电子表格中移动数据,我是否需要使用VBA? 如果是这样,我将如何去做?

[英]Moving data in an Excel spreadsheet, will I need to use VBA? If so, how would I go about doing it?

as cliche as it sounds, long time reader, first time poster. 听起来陈词滥调,长期的读者,第一次的海报。 I'm currently helping a family member out with some work and he has to sort through several thousand records and slightly change the format, obviously without some sort of automation it would take tens of hours and he asked me if I could help do it quickly. 我目前正在帮助一位家庭成员完成一些工作,他必须整理几千条记录并稍稍更改格式,显然如果没有某种自动化,这将需要数十个小时,他问我是否可以快速完成工作。 At first I thought I could, but I'm a little over my head with some of this stuff. 起初我以为可以,但是我对其中的一些东西有些不满意。

Basically, he has this data in this type of format: 基本上,他具有以下格式的数据:

Sample No 
1         Ag 20
1         Au 50
1         Cu 80
2         AG 1
2         Au 30
3         Cu 30

But we need the data like this: 但是我们需要这样的数据:

Sample No. Ag Au Cu
1          20 50 80
2          1  30 -
3          -  -  30

At first I thought I could do it with a formula to move the data horizontally. 起初,我以为可以用公式来水平移动数据。 The only problem is the missing data would preferably be filled with a '-', but in the original data given they are just left out entirely, so Im assuming I'll need VBA. 唯一的问题是丢失的数据最好用'-'填充,但在给定的原始数据中,它们被完全遗漏了,因此我假设我需要VBA。

Sorry if I left anything out, but any pointers in the right direction with VBA would be incredibly handy. 抱歉,如果我遗漏了任何内容,但是使用VBA指向正确方向的任何指针将非常方便。

Thanks 谢谢

EDIT: Fixed formatting and had two numbers switched, sorry guys. 编辑:固定格式,并切换了两个数字,对不起。

You can use Pivot Tables for this. 您可以为此使用数据透视表

Assuming your data is currently in a single column, you can do the following: 假设您的数据当前在单个列中,则可以执行以下操作:

  1. Data menu > Text To Columns, split on a space 数据菜单>文本到列,在空格上拆分
  2. With your three new columns, insert a row into A1 在三个新列中,在A1中插入一行
  3. Give your three columns captions, such as Sample, Element and Size 输入三列标题,例如“样本”,“元素”和“大小”
  4. Highlight your entire range, and select Data menu > Pivot Table and PivotChart report... 突出显示您的整个范围,然后选择“数据”菜单>“数据透视表”和“数据透视图”报告...
  5. Select "Microsoft Office Excel list or database", and press "Next" 选择“ Microsoft Office Excel列表或数据库”,然后按“下一步”
  6. Select "New Worksheet" if you want the data in a new worksheet 如果要在新工作表中添加数据,请选择“新工作表”
  7. From here, drop your Sample element into the left side of the table, the Element element into the top side of the table, and the Size element into the middle of the table. 从这里,将Sample元素放到表的左侧,将Element元素放到表的顶部,将Size元素放到表的中间。

You won't have dashes for your missing data, but this should do what you want. 丢失的数据不会破折号,但这应该可以实现您想要的。

暂无
暂无

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

相关问题 我正在尝试写入/粘贴我刮到特定 Excel 电子表格单元格位置的数据,但我不知道如何去做 - I'm trying to write/paste data I have scraped into a specific excel spreadsheet cell location, but I'm not sure how to go about doing it 我可以使用内置的Excel解算器以某种方式解决这个等式吗? 如果没有,你会怎么做? - Can I use a built-in Excel solver to solve this equation somehow? If not, how would you go about it? 如何使用VBA自动使用来自单独的excel工作簿的数据透视表的数据填充excel工作表? - How would I use VBA to automatically populate an excel worksheet with data from the pivot table of a separate excel workbook? 如何使用VBA在Excel中添加连接(到外部数据源)并将其保存到Excel电子表格的连接列表中 - How can I use VBA to add a Connection (to an External Data Source) in Excel and Save it to that Excel spreadsheet's list of Connections 我将如何在Excel中的VB中循环一个月中的特定日期 - How would I go about looping a specific date in a month in VB for excel 我将如何搜索,然后将已知结构的值从一个excel文件导入另一个文件? - How would I go about searching for, and then importing values of a known structure from one excel file to another? 我可以在 VBA 中使用 .res (资源)文件吗?这样做有好处吗? - Can I use .res (resource) files in VBA and is there an advantage to doing so? 如何将数据添加到Excel电子表格? - How can I add data to an Excel spreadsheet? 如何使用VBA将Excel 2016数据导出到另一个电子表格中? - How do I export Excel 2016 data into another spreadsheet using VBA? 如何使用VBA for Microsoft Excel使用ftp将数据下载到电子表格 - How can I download data using ftp to a spreadsheet with VBA for Microsoft Excel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM