我正在尝试从访问db VBA填写excel表中的公式。我引用了this
这是我的代码
Dim xlApp As Excel.Application
Dim wb As Workbook
Dim strFormulas(1 To 4) As Variant
txtcatpath = Form_Bom.Excelpath.Value
Set xlApp = CreateObject("Excel.Application")
With xlApp
Set wb = .Workbooks.Open(txtcatpath)
.Visible = True
End With
With wb.Sheets("common based")
strFormulas(1) = "=IF(F4<>F5,E4,E4&""&H5)"
strFormulas(2) = "=VLOOKUP(J4,F:H,3,FALSE)"
strFormulas(3) = "=IF(COUNTIF(F4:F900,F4)=1,F4,"")"
strFormulas(4) = "=SUMIF(F:F,J4,G:G)"
.Range("H4:K4").Formula = strFormulas
.Range("H4:K" & LRow & "").FillDown
End With
调试时,我的代码在.Range("H4:K4").Formula = strFormulas
中被破坏了。如何用公式填充列。