이 사이트에서 검색했지만 내 문제에 대한 답을 찾을 수 없습니다. VB 2010 Express를 사용하고 있습니다. Excel 스프레드 시트에 수식을 쓰려고합니다.상단 및 하단 코드는 정상적으로 작동하지만 위 공식은 작동하지 않습니다.
oWorkSheet = oBook.Sheets(STRName)
'my variables are all declared strings
'this section works
FMLAValue1 = "=-L8"
FMLAValue2 = "=SUM($I$7;$F$8:$H$8)"
FMLAValue3 = "=SUM(M8:U8)"
oWorkSheet.Range("H8").Select()
oWorkSheet.Range("H8").Formula = FMLAValue1
oWorkSheet.Range("H8").AutoFill (oWorkSheet.Range("H8:H40"))
'up to here
'now this is the problem code below: if I paste the formula into a
'excel sheet cell, it works.
oWorkSheet.Range("I8").Select()
oWorkSheet.Range("I8").Formula = FMLAValue2
'**the line above gives an "Exception from HRESULT: 0x800A03EC "**
oWorkSheet.Range("I8").AutoFill (oWorkSheet.Range("I8:I40"))
'this part also works
oWorkSheet.Range("L8").Select()
oWorkSheet.Range("L8").Formula = FMLAValue3
oWorkSheet.Range("L8").AutoFill (oWorkSheet.Range("L8:L40"))
oWorkSheet.Range("J7").Select()
oWorkSheet.Range("J7").Formula = "=I7"
사용해보십시오'대신 Formula''의 FormulaLocal', 또는 쉼표로 세미콜론을 교체합니다. –