简体   繁体   中英

Assign Macro to Command Button Fail

I have written a macro which is working smoothly for approximately 1,000 rows when I run it in the Developer but when I link it to a command button and start it by pressing the button it is just executing it for one row.

Does someone know what is going wrong here and how to solve this issue? Thanks :)

Sub AutomaticallyCalculateted()

Dim lastrow As Long

lastrow = Range("A" & Rows.Count).End(xlUp).Offset(8).Row


Tabelle3.Range("O9:O" & lastrow).FormulaLocal = "=WENN(ODER(K9="""";L9="""");"""";WENNFEHLER((L9-K9)/K9;""""))"


Tabelle3.Range("P9:P" & lastrow).FormulaLocal = "=WENN(ODER(L9="""";M9="""");"""";WENNFEHLER((M9-L9)/L9;""""))"


Tabelle3.Range("Q9:Q" & lastrow).FormulaLocal = "=WENN(ODER(M9="""";N9="""");"""";WENNFEHLER((N9-M9)/M9;""""))"

End Sub

您的lastRow是在ActiveSheet上定义的,但是您的公式正在进入Tabelle3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM