![]() |
Sin Button run macro Excel 2000 - 2003
Hello,
I put a worksheet toolbar Spinner Button on worksheet6 and my reference cell is on worksheet2. This code I put in worksheet6 module: Private Sub SpinButton1_SpinUp() Sheet2.Range("M4").Value = Sheet2.Range("M4").Value + 1 End Sub Private Sub SpinButton1_SpinDown() Sheet2.Range("M4").Value = Sheet2.Range("M4").Value - 1 End Sub Then, I assigned this macro to the spin button using a general module: Sub InDecreaseYear() If Sheet2.Range("M4") = 1 Then Call DateTesterBaselineIncrease Call BuildCalendar_North End If If Sheet2.Range("M4") = 2 Then Call DateTesterBaselineDecrease Call BuildCalendar_North End If End Sub This code will change the value in the cell from 1 to 2 and back to 1 but it will not run the macros to decrease the value it will only run the macros to increase the value. How can this code be changed when the spin button up is pressed those macros will run and when pressed down those macros will run? Thank you for your help, jfcby |
Sin Button run macro Excel 2000 - 2003
Hello,
Thank you for your help! The changes to hthe code works great! jfcby John Bundy wrote: I plugged your code in and it worked fine, looks like you need to set up an on change event and place your two pieces in there. -- -John Please rate when your question is answered to help us and others know what is helpful. "jfcby" wrote: Hello, I put a worksheet toolbar Spinner Button on worksheet6 and my reference cell is on worksheet2. This code I put in worksheet6 module: Private Sub SpinButton1_SpinUp() Sheet2.Range("M4").Value = Sheet2.Range("M4").Value + 1 End Sub Private Sub SpinButton1_SpinDown() Sheet2.Range("M4").Value = Sheet2.Range("M4").Value - 1 End Sub Then, I assigned this macro to the spin button using a general module: Sub InDecreaseYear() If Sheet2.Range("M4") = 1 Then Call DateTesterBaselineIncrease Call BuildCalendar_North End If If Sheet2.Range("M4") = 2 Then Call DateTesterBaselineDecrease Call BuildCalendar_North End If End Sub This code will change the value in the cell from 1 to 2 and back to 1 but it will not run the macros to decrease the value it will only run the macros to increase the value. How can this code be changed when the spin button up is pressed those macros will run and when pressed down those macros will run? Thank you for your help, jfcby |
All times are GMT +1. The time now is 11:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com