发布网友 发布时间:2022-04-19 14:23
共1个回答
热心网友 时间:2023-10-25 07:33
Try this one:Sub 锻煎彨寤虹珛() Dim ActiveData ActiveData = ActiveSheet.Value Sheets.Add Before:=Sheets(1) Sheets("锻煎彨寤虹珛鎴愬姛鐜?).Select fileToOpen = Application.GetOpenFilename("", , , , True) If VarType(fileToOpen) = vbBoolean Then MsgBox "No files selected!" Else For Each fn In fileToOpen Application.Run "娴奶瘯.xls!DateFormat" Sheets("锻煎彨寤虹珛鎴愬姛鐜?).Select If ActiveData <> Sheets(1).Cells(2, 2).Value Then MsgBox "You choose the wrong files" Else Application.Run "娴奶瘯.xls!ImportData(fn)" Sheet(1).Range("F4").Copy If Shee1(1).Cells(2, 3).Value = "08" Then ActiveCell.Offset(0, 1).Paste If Shee1(1).Cells(2, 3).Value = "09" Then ActiveCell.Offset(0, 2).Paste If Shee1(1).Cells(2, 3).Value = "10" Then ActiveCell.Offset(0, 3).Paste If Shee1(1).Cells(2, 3).Value = "18" Then ActiveCell.Offset(0, 4).Paste If Shee1(1).Cells(2, 3).Value = "19" Then ActiveCell.Offset(0, 5).Paste If Shee1(1).Cells(2, 3).Value = "20" Then ActiveCell.Offset(0, 6).Paste End If Next If ActiveCell.Offset(0, 1) <> "" And ActiveCell.Offset(0, 2) <> "" And ActiveCell.Offset(0, 3) <> "" And ActiveCell.Offset(0, 4) <> "" And ActiveCell.Offset(0, 5) <> "" And ActiveCell.Offset(0, 6) <> "" Then Active.Cell.Offset(0, 7).FormulaR1C1 = "=AVERAGE(ActiveCell.Offset(0,1),ActiveCell,Offset(0,6))" End If End Sub