简体   繁体   中英

How to run a calculation in a sheet using button in excel

I am trying to create an form control or activex command button to change a series of values to a particular calculation.

My button is on a sheet named "Sheet 2" and the calculation needs to happen on a sheet named "Whatif back".

When i press the button, C2 in "Whatif back" must be calculated with C27 in "Sheet 2".

My code is:

Sub Sheet2_Button18_Click()
Sheets("Whatif back").Range("C2")=(10000+Sheets("Sheet2").Range(C27))
End Sub

I am getting a compile error. Please help.

Thank you, Shyam

with an ActiveX button named after "Sheet2_Button18" in worksheet "Sheet2" you use this:

Sub Sheet2_Button18_Click()
    Sheets("Whatif back").Range("C2") = 10000 + Range("C27")
End Sub

Nice to know what compile error you're getting, but try: Range("C27") instead of Range(C27)

(this should be a comment but I don't have rep yet)

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