[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
还是让合适的工具来做最适合的工作吧,以前我先用bat来处理数据,发现效率太低了,后来又用bat调用vbs处理,感觉没那么顺手,接触到vba后,哈哈,有了相见恨晚的感觉...
我想,可能batman还不知道excel里有一个叫做vba(快捷键为Alt+F8)的东西吧,用VBE(快捷键Alt+F11)编写的,用下面的代码(vba)就高效多了,哈哈...
  1. Option Explicit
  2. Sub JustDoIt()
  3.   Dim AllColumns As Integer, AllRows As Integer, i As Integer, j As Integer, ADuty As Integer, Info As String, _
  4.     Info2 As String
  5.   AllColumns = Range("iv1").End(xlToLeft).Column       '获取数据区列数
  6.   AllRows = Range("a65536").End(xlUp).Row              '获取数据区行数
  7.   For i = 2 To AllColumns - 2
  8.     Info = ""
  9.     ADuty = 0
  10.     For j = 2 To AllRows
  11.       If Cells(j, i) > 0 Then
  12.         ADuty = ADuty + Cells(j, i)
  13.       Else
  14.         Info = Info & Cells(j, 1) & ","
  15.       End If
  16.     Next
  17.     If Info = "" Then Info = "无"
  18.     Cells(i, AllColumns + 1) = Cells(1, i) & ADuty & ", 完成为 0 的局: " & Info
  19.   Next
  20.   Info = "当日排名: "
  21.   Info2 = "当月累计排名: "
  22.   For i = 1 To AllRows
  23.     For j = 2 To AllRows
  24.       If Cells(j, AllColumns - 1) = i Then Info = Info & Cells(j, 1) & i & ","
  25.       If Cells(j, AllColumns) = i Then Info2 = Info2 & Cells(j, 1) & i & ","
  26.     Next
  27.   Next
  28.   Cells(AllColumns, AllColumns + 1) = Info & vbCrLf & Info2
  29.   Columns(AllColumns + 1).AutoFit
  30.   Cells(AllColumns, AllColumns + 1).Select
  31. End Sub
复制代码

TOP

函数完成不了1楼要求的显示效果吧,而在33楼你却说实际工作中是用vbs来操作的嘛...还生成一个b.txt...

TOP

返回列表