我已附上excel文件的代码段,其中B列是所需的输出。这种类似的逻辑在宏中起作用,但是根据我们的要求,我们需要为其构建一个VBScript。下面是我的代码
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
Set inputExcelWorkbook = oExcel.Workbooks.Open("C:\...\Test1.xlsx")
Set inputExcelSheet = inputExcelWorkbook.ActiveSheet
inputExcelSheet.Range("A2:A11").AdvancedFilter _
xlFilterCopy,,inputExcelSheet.Range("B2"),True
inputExcelWorkbook.save
inputExcelWorkbook.close
答案 0 :(得分:0)
所以,当我不使用xlFilterCopy而是按照@ nick.McDermaid建议使用“ 2”时,我的问题得到解决
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
Set inputExcelWorkbook = oExcel.Workbooks.Open("C:\...\Test1.xlsx")
Set inputExcelSheet = inputExcelWorkbook.ActiveSheet
inputExcelSheet.Range("A2:A11").AdvancedFilter _
2,,inputExcelSheet.Range("B2"),True
inputExcelWorkbook.save
inputExcelWorkbook.close