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)表示数组的上限