当我将数据添加到我的工作簿时,将公式从较早的单元格复制到新单元格是必要的.
我使用以下公式计算我的增长率:
=WENN(ODER(K9="";L9="");"";WENNFEHLER((L9-K9)/K9;""))
Run Code Online (Sandbox Code Playgroud)
由于这非常耗时,我想用宏来改进它,并因此编写了以下代码:
Sub Growth()
Tabelle3.Range("O9").Formula = "=WENN(ODER(K9="";L9="");"";WENNFEHLER((L9-K9)/K9;""))"
Tabelle3.Range("O9:O14").FillDown
End Sub
Run Code Online (Sandbox Code Playgroud)
但是,当我想运行代码"运行时错误'1004':应用程序定义或对象定义错误"时,此行会出现:
Tabelle3.Range("O9").Formula = "=WENN(ODER(K9="";L9="");"";WENNFEHLER((L9-K9)/K9;""))"
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么会出现这个错误以及如何解决它?
我想在两个场景中使用if-function来进行distingiush.
For Each Cell In Tabelle3.Range("A" & lastrow2)
Option A: If Cell <> "" Then run code
Option B: If Cell = "" Then skip this empty cell and go on with the next one
Run Code Online (Sandbox Code Playgroud)
这里整个代码:
Sub IfFunction()
Dim lastrow2 As Long
lastrow2 = Tabelle3.Range("A" & Rows.Count).End(xlUp).Row
Set myrange2 = Tabelle8.UsedRange
For i = 2 To lastrow2
For Each Cell In Tabelle3.Range("A" & lastrow2)
If Cell = "" Then i = i + 1
Else: i = i
Tabelle3.Cells(7 + …Run Code Online (Sandbox Code Playgroud)