![]() |
Toggle Button
Hi all, I am looking a putting a VB command button on one of my sheets, which when pressed once it does one thing, then when pressed again it does something different. e.g. when pressed first time it hides a range of rows, when pressed again it unhides them. Hope you can help Dave -- Dave_2k5 ------------------------------------------------------------------------ Dave_2k5's Profile: http://www.excelforum.com/member.php...o&userid=19667 View this thread: http://www.excelforum.com/showthread...hreadid=401061 |
Toggle Button
Good morning Dave_2k5 Why not set up a check box from the control toolbox toolbar. Once you've drawn it on screen double click on it and paste the code below into the window that opens. Close the window to return to Excel and on the Control Toolbox bar select Design Mode (top left) to set the checkbox. The code shown assumes that your checkbox will be called Checkbox1 and that you want to hide rows 10 to 15 inclusive. Private Sub CheckBox1_Click() If CheckBox1.Value = True Then Rows("10:15").EntireRow.Hidden = True Else Rows("10:15").EntireRow.Hidden = False End If End Sub HTH DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=401061 |
Toggle Button
I would do that......But want it to be a button not a checkbox!! Cheers Anyway Dave -- Dave_2k5 ------------------------------------------------------------------------ Dave_2k5's Profile: http://www.excelforum.com/member.php...o&userid=19667 View this thread: http://www.excelforum.com/showthread...hreadid=401061 |
Toggle Button
Hi Dave If it HAS to be a button then have a look in the control toolbox - there is a toggle button. Don't use the forms toolbar because there isn't one there. HTH DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=401061 |
All times are GMT +1. The time now is 12:37 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com