XLXRider
Board Regular
- Joined
- Jul 31, 2004
- Messages
- 180
Good morning...
I have a really crumby form that I've been tasked with updating. I need to have a few boxes that Excel-challenged users can readily check and/or uncheck. I don't want to use checkbox... so what I've done is made an object and placed an "X" in it, or not. The code to do one or the other is a snap, but what I want to do is combine the code into a command button, and I will make one command button for each check/uncheck instance since there are only 5 or 6 in the entire form. Here's my problem:
I can't seem to get the conditional statement to work, and don't know if it's because conditional statements won't work with objects or because I'm doing it incorrectly!
Here's the code I've been working with:
Sub toggleX()
ActiveSheet.Shapes("XBoxEmpty").Select
With Selection.Characters.Text
If .Shapes("XBoxEmpty").Characters.Text = "" Then
.Shapes("XBoxEmpty").Characters.Text = "X"
Else
.Shapes("XBoxEmpty").Characters.Text = ""
End If
End With
End Sub
The object name I'm working with in my experiments is XBoxEmpty, and I want the user to look at the box and be able to change the state from "X" to "" with the same button. That is, if the user puts in an X and realizes it should be empty, the same button does it. And vice-versa.
Thanks in advance,
XLXRider
I have a really crumby form that I've been tasked with updating. I need to have a few boxes that Excel-challenged users can readily check and/or uncheck. I don't want to use checkbox... so what I've done is made an object and placed an "X" in it, or not. The code to do one or the other is a snap, but what I want to do is combine the code into a command button, and I will make one command button for each check/uncheck instance since there are only 5 or 6 in the entire form. Here's my problem:
I can't seem to get the conditional statement to work, and don't know if it's because conditional statements won't work with objects or because I'm doing it incorrectly!
Here's the code I've been working with:
Sub toggleX()
ActiveSheet.Shapes("XBoxEmpty").Select
With Selection.Characters.Text
If .Shapes("XBoxEmpty").Characters.Text = "" Then
.Shapes("XBoxEmpty").Characters.Text = "X"
Else
.Shapes("XBoxEmpty").Characters.Text = ""
End If
End With
End Sub
The object name I'm working with in my experiments is XBoxEmpty, and I want the user to look at the box and be able to change the state from "X" to "" with the same button. That is, if the user puts in an X and realizes it should be empty, the same button does it. And vice-versa.
Thanks in advance,
XLXRider