永发信息网

在EXCEL中用VB统计数据

答案:3  悬赏:0  手机版
解决时间 2021-03-15 23:57
  • 提问者网友:两耳就是菩提
  • 2021-03-15 16:23
把EXCEL表中的数据金额一一统计出100元的数量50元的数量20元的数量及10元的数量5元数量和1元的数量,小数暂不需要

我试了但是结果出来是0,不知道为什么哦....
我想再描述一下我的意思,比如说表中金额这一列中有三个数:256,120,319,分别统计出这三个数的100张数和50元张数20元张数10元张数5元张数1元张数,其计算结算应该是100为6,50为1,20为1 ,10 为1 ,5为2 ,1为5
最佳答案
  • 五星知识达人网友:鸽屿
  • 2021-03-15 16:40
请在www.EXCELHOME.NET论坛上索取该 零钞程序~或者qq:28213938索取
全部回答
  • 1楼网友:刀戟声无边
  • 2021-03-15 19:46
放置一个commondialog1控件用于选择excel文件 private sub command1_click() dim i as long dim sum1, sum2 as long dim vbexcel as excel.application dim xlbook as excel.workbook dim xlssheet as excel.worksheet set vbexcel = createobject("excel.application") commondialog1.filename = "" commondialog1.filter = "excel文件(*.xlsx)|*.xlsx" commondialog1.showopen if commondialog1.filename = "" then  exit sub  else   set xlbook = vbexcel.workbooks.open(commondialog1.filename)   set xlssheet = xlbook.worksheets(1)   vbexcel.visible = true   for i = 2 to 35535    if xlssheet.cells(i, 1) = "" then     exit for     else     if xlssheet.cells(i, 1) = "张三" then '检查第i行,第一列数据,自己可以定义     sum1 = sum1 + xlssheet.cells(i, 2)     end if     if xlssheet.cells(i, 1) = "李四" then     sum2 = sum2 + xlssheet.cells(i, 2)     end if       end if  next end if text1.text = sum1 text2.text = sum2 xlbook.close (true) set xlssheet = nothing set xlbook = nothing set vbexcel = nothing end sub
  • 2楼网友:慢性怪人
  • 2021-03-15 18:13
直接使用Countif函数就可以呀,如统计一百元的数量。(例如数据范围是A1:G10),选择数据结果单元格后,使用函数: =COUNTIF(A1:G10,"=100")
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯