Command Button
Hello, I am trying to do the following:
When I press the command button, the statement "Market Order" appears in cell B1, however when I press it again it will remove the statement "Market Order". Sort of like an on and off switch. I have written the following so far, however I am having trouble in removing the statement when I press the command button again. Your help is appreciated Private Sub CommandButton1_Click() If CommandButton1.Value = True Then Range("B1").Value = "Market Order" Else Range("B1").Value = "" End if End Sub Thank you Mike |
Command Button
Private Sub CommandButton1_Click()
If CommandButton1.Value = True and Range("B1").value ="" Then Range("B1").Value = "Market Order" If CommandButton1.Value = True and Range("B1").value <"" Then Range("B1").Value = "" End Sub wrote in message ... Hello, I am trying to do the following: When I press the command button, the statement "Market Order" appears in cell B1, however when I press it again it will remove the statement "Market Order". Sort of like an on and off switch. I have written the following so far, however I am having trouble in removing the statement when I press the command button again. Your help is appreciated Private Sub CommandButton1_Click() If CommandButton1.Value = True Then Range("B1").Value = "Market Order" Else Range("B1").Value = "" End if End Sub Thank you Mike |
Command Button
Give this a try...
Private Sub CommandButton1_Click() If Len(Me.Range("B1")) 0 Then Me.Range("B1").Value = vbNullString Else Me.Range("B1").Value = "Market Order" End If End Sub -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware wrote in message Hello, I am trying to do the following: When I press the command button, the statement "Market Order" appears in cell B1, however when I press it again it will remove the statement "Market Order". Sort of like an on and off switch. I have written the following so far, however I am having trouble in removing the statement when I press the command button again. Your help is appreciated Private Sub CommandButton1_Click() If CommandButton1.Value = True Then Range("B1").Value = "Market Order" Else Range("B1").Value = "" End if End Sub Thank you Mike |
All times are GMT +1. The time now is 05:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com