- Set ExcelApp = CreateObject("Excel.Application")
- Set ExcelBook = ExcelApp.Workbooks.open("ExcelFile.XLS") 'XLS表格文件
- Set ExcelSheet = ExcelBook.Worksheets("Sheet1") '引号中为工作表名
- ExcelSheet.Activate
- RowCount = ExcelBook.ActiveSheet.UsedRange.Rows.Count
- For i = 1 to RowCount
- If CSTR(ExcelSheet.Cells(i,5)) = "早班" then MW = i 'MW代表早班
- If CSTR(ExcelSheet.Cells(i,5)) = "午班" then NW = i 'NW代表午班
- If CSTR(ExcelSheet.Cells(i,5)) = "晚班" then 'EW代表晚班
- EW = i
- Exit For
- end if
- Next
-
- 'objExcel.Range("I" & (第一个早班行号) & ":I" & (第一个午班行号)).Value = 哈哈
- '上句改成
- ExcelSheet.Range("I" & MW & ":I" & NW).Value = 哈哈
-
- ExcelBook.Close
复制代码
|