返回列表 发帖
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.CloseCOPY

TOP

回复 4# hkxinghu

C.Row 就是你要引号的行号阿
你也可以设置一个变量 Line,然后引用这个变量,如下:
Line = C.Row

TOP

返回列表