0
我在这个论坛和网上搜索了很多,但找不到解答我的答案。使用vb.net在excel中输入公式
我需要使用我创建的visual studio(2013)窗体在Excel中输入公式。我输入了所需的命令,但它显示了错误的行。
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
xlWorkBook = xlApp.Workbooks.Open("C:\Users\Desktop\14.xlsx")
'xlApp.Visible = True
xlWorkSheet = xlWorkBook.Sheets("Sheet1")
'xlWorkSheet.Unprotect()
Dim iRow As Long
iRow = 5 'have lots of headers so finally empty row starts on 5th
With xlWorkSheet
Do While .Cells(iRow, 2).value <> ""
.Cells(iRow, 2).activate()
iRow = iRow + 1
Loop
.Cells(iRow, 2).Value = t1.Text
.Cells(iRow, 3).Value = t2.Text
.Cells(iRow, 5).Value = t4.Text
.Cells(iRow, "AB").FormulaR1C1 = "=IF(R[" & iRow & "]C22<R[" & iRow & "]C27,""Yes"",""No"")"
End With
它进入在正确的行(irow值),但式而不是显示V5' <‘AA5(5递增与每个插入)它显示V10’<“AA10英寸为什么? 我试图定义一个整型变量,然后用2除iRow值,但仍然无法正常工作。
请帮忙!
为什么你有'.Cells(iRow,2).Activate'?这在你的日常工作中没有做任何事情,但我认为你期待它做些什么? – BruceWayne
雅没有做任何事情。我删除了那个 – user5538704