再来一下: | arrCell = Array("D37", "D38", "D39") | | Set fso = CreateObject("Scripting.FileSystemObject") | | For Each file in fso.GetFolder(".").Files | | If LCase(Right(file, 4)) = ".csv" Then | | Set f = fso.OpenTextFile(file, 1) | | txt = f.ReadAll : f.Close | | str = str & getCellsData(txt) & vbCrLf | | End If | | Next | | | | fso.OpenTextFile("new.csv", 2, true).Write str | | MsgBox "OK" | | | | Function getCellsData(ByVal txt) | | | | arrTxt = Split(txt, vbCrLf) | | strChr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | | | | Set re = New RegExp | | | | re.Pattern = "^([a-z]{1,2})(\d+)$" | | re.IgnoreCase = true | | For i = 0 to UBound(arrCell) | | n = re.Execute(arrCell(i))(0).SubMatches(0) | | n = UCase(Right("0" & n, 2)) | | n1 = InStr(strChr, Left(n, 1)) | | n2 = InStr(strChr, Mid(n, 2)) | | n = n1 * 26 + n2 - 1 | | m = re.Execute(arrCell(i))(0).SubMatches(1) - 1 | | s = s & "," & Split(arrTxt(m), ",")(n) | | Next | | getCellsData = Mid(s, 2) | | End FunctionCOPY |
|