简体   繁体   English

Excel VBA报表,按条件选择单元格

[英]Excel VBA Report, Selecting Cells by a criteria

I have this Excel 我有这个Excel

在此处输入图片说明

now i want to make some reports using a VBA Macro 现在我想使用VBA宏进行一些报告

Report 1 (select all tasks) 报告1(选择所有任务)

Select the number of total tasks no matter if they are completed or not IMPORTANT! 选择总任务数,无论它们是否完成都重要! Keep in mind that here are 5 tasks, in another excel may be 20 30 , but all have the same format C6 - task_id, D6 - task_name, E6 task_name ... and so on 请记住,这是5个任务,在另一个excel中可能是20 30,但所有任务都具有相同的格式C6-task_id,D6-task_name,E6 task_name ...等

Report 2 (select all WHERE completed is 100%) 报告2(选择所有在100%完成的位置)

Select the number of total tasks where completed column is 100% IMPORTANT! 选择完成的列为100%重要的任务总数。 Keep in mind that here are 5 tasks, in another excel may be 20 30 , but all have the same format C6 - task_id, D6 - task_name, E6 task_name ... and so on 请记住,这是5个任务,在另一个excel中可能是20 30,但所有任务都具有相同的格式C6-task_id,D6-task_name,E6 task_name ...等

Report 3 (select all users and retrive information about their productivity) 报告3(选择所有用户并检索有关其工作效率的信息)

Here basicaly i need something like 在这里,我基本上需要

SUM(I6:I10) - SUM(K6:K10) WHERE task_given_to = 'OM'

SUM(I6:I10) - SUM(K6:K10) WHERE task_given_to = 'MN'

SUM(I6:I10) - SUM(K6:K10) WHERE task_given_to = 'NM'

IMPORTANT! 重要! Keep in mind that here are 5 tasks, in another excel may be 20 30 , but all have the same format C6 - task_id, D6 - task_name, E6 task_name ... and so on 请记住,这是5个任务,在另一个excel中可能是20 30,但所有任务都具有相同的格式C6-task_id,D6-task_name,E6 task_name ...等

Any help with that? 有什么帮助吗?
I must say, in SQL it would be easy ... 我必须说,在SQL中这很容易...

Is there any requirement to use VBA ? 使用VBA是否有任何要求? Unless there is something I am missing, a simple pivot table would be able to do that. 除非有我缺少的东西,否则一个简单的数据透视表就可以做到这一点。

  1. Just put the task name as the row field. 只需将任务名称作为行字段即可。
  2. Apply a filter on completion. 完成时应用过滤器。
  3. User as row field, productivity as data, task type as column. 用户为行字段,生产力为数据,任务类型为列。

Isn't it what you are trying to achieve ? 这不是您要达到的目标吗?

Oh and FYI if this does come from Access you can use MS Query. 哦,仅供参考,如果这确实来自Access,则可以使用MS Query。 Data => Other sources => MS Query => Access database 数据=>其他来源=> MS查询=>访问数据库

Then you can just use an SQL query to retrieve data. 然后,您可以仅使用SQL查询来检索数据。 I'd then make 3 data sheets with 3 different queries and 3 report sheets which would format the data to a more report-like format. 然后,我将制作3个带有3个不同查询的数据表和3个报告表,以将数据格式化为更类似于报告的格式。

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

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