TextBox1.Text中存入的是一个长字符串,通过split函数按 " " 进行分割,存入ReDat() 数组中。FileCopy 复制文件,将 ReDat() 中的元素赋给 拷贝文件中指定的对象,然后进行保存。
Dim ReDate() As String
Dim i As Integer
ReDate = Split(TextBox1.Text, " ")
For i = LBound(ReDate) To UBound(ReDate) - 1
'LBound(ReDate) 表示数组的下限,为0 UBound(ReDate)表示数组的上限
'MsgBox ("*****" + ReDate(i))
FileCopy reviewFormatPath, reviewFormatPath & "temp" '复制文件
Set Tempwb = Workbooks.Open(reviewFormatPath & "temp") '打开文件
Tempwb.Worksheets("sheet1").Activate ’打开文件工作簿
Cells(6, 9).Value = ComboBox1s '给工作簿中的单元格赋值
Tempwb.Save '保存工作簿
Tempwb.Close
Next i
Unload UserForm2 '表示卸载窗体
- LBound(ReDate) 表示数组的下限,返回值为0
- UBound(ReDate)表示数组的上限
该博客内容涉及使用VBScript进行字符串处理,通过Split函数将TextBox1中的长字符串按特定分隔符分割成数组ReDate。接着,遍历数组并利用FileCopy进行文件复制,然后在打开的工作簿中更新指定单元格的值,并保存工作簿。整个过程实现了数据从文本到Excel文件的迁移。

被折叠的 条评论
为什么被折叠?



