'定义一个函数,把业务状况表的数据加载到字典里
Public Function AddDictionary(OriginalDictionary)
Dim Path, CurrentWorkBook, CurrentWorkSheet, CurrentName
Dim str1, str2, str3, str4, str5, str6
Dim n
n = 10
'打开名称里含有业务状况表的表格
Path = ThisWorkbook.Path & "\*业务状况表*"
'Dir函数返回路径下的文件名称,再次调用自动查找下一个符合条件的文件
CurrentName = Dir(Path)
Set CurrentWorkBook = Workbooks.Open(ThisWorkbook.Path & "\" & CurrentName)
Set CurrentWorkSheet = CurrentWorkBook.Worksheets(1)
'VB字典的定义和应用!
Set OriginalDictionary = CreateObject("Scripting.Dictionary")
While CurrentWorkSheet.Cells(n, 1) <> ""
str1 = "BD" & CurrentWorkSheet.Cells(n, 1)
str2 = "BC" & CurrentWorkSheet.Cells(n, 1)
str3 = "MD" & CurrentWorkSheet.Cells(n, 1)
str4 = "MC" & CurrentWorkSheet.Cells(n, 1)
str5 = "ED" & CurrentWorkSheet.Cells(n, 1)
str6 = "EC" & CurrentWorkSheet.Cells(n, 1)
OriginalDictionary.Add str1, CurrentWorkSheet.Cells(n, 3).Value
OriginalDictionary.Add st
VB语言自动化处理字符串函数
最新推荐文章于 2023-07-22 14:29:27 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)