我输入了允许我将子窗体结果导出到excel工作簿/工作表中的代码。我已经命名了范围,但是当我查看应该显示比率的列时,即使子窗体在行中具有值,它也只显示0。
我尝试直接导入整个文件,但是无法正常工作。我已经修改过了,但无济于事。
Private Sub Command24_Click()
Dim appexcel As Excel.Application
Dim ExcelBook As Excel.Workbook
Dim ExcelSheet As Excel.Worksheet
Dim NameofBook As String
Set appexcel = Excel.Application
Set ExcelBook = Excel.Workbooks.Open("C:\Users\Aiden\Desktop\access folder\VExport1.xlsx")
Set ExcelSheet = ExcelBook.Worksheets("VExport")
ExcelSheet.Range("B2:B1499").FormulaR1C1 = Me.[SearchQ subform].Form.[VENDOR NAME]
ExcelSheet.Range("C2:C1499").FormulaR1C1 = Me.[SearchQ subform].Form.[Vendor No]
ExcelSheet.Range("J2").FormulaR1C1 = Me.[SearchQ subform].Form.[Rental Day]
ExcelSheet.Range("K2").FormulaR1C1 = Me.[SearchQ subform].Form.[Rental Week]
ExcelSheet.Range("L2").FormulaR1C1 = Me.[SearchQ subform].Form.[Rental Month]
'Make the instance of Excel visible
appexcel.Visible = True
'Clean up memory
Set ExcelSheet = Nothing
Set ExcelBook = Nothing
Set appexcel = Nothing
End Sub
如我所愿,最高范围将供应商名称和编号填充到整个列中,但是租用日/周/月中的值不会超过。我试图列出导出的范围,但是它不会更改值,我还消除了模板文件中的零,希望它只是选择不覆盖已经存在的数据,但没有任何效果。