mrmmickle1
Well-known Member
- Joined
- May 11, 2012
- Messages
- 2,461
I was hoping to see if the inputbox was canceled.
I have tried several things so far:
1. changing datatype to a variant and testing for False with no luck.
2. I have also tried testing for vbCancel with no luck.
3. I have also tried testing for VarType() and then handling things differently if Boolean....
Is it possible to collect this information. The issue is the input defaults to have whatever cell is selected in it initially. So when the user presses cancel it inserts a checkbox anyways. Even though the user has clicked cancel....
Any help would be appreciated:
I believe this source code originated from KuTools Website.
I have tried several things so far:
1. changing datatype to a variant and testing for False with no luck.
2. I have also tried testing for vbCancel with no luck.
3. I have also tried testing for VarType() and then handling things differently if Boolean....
Is it possible to collect this information. The issue is the input defaults to have whatever cell is selected in it initially. So when the user presses cancel it inserts a checkbox anyways. Even though the user has clicked cancel....
Any help would be appreciated:
I believe this source code originated from KuTools Website.
Code:
[COLOR=#0000ff][B]Sub [/B][/COLOR]InsertCheckBoxes()
[COLOR=#0000ff][B] Dim[/B][/COLOR] Rng[COLOR=#0000ff][B] As Range[/B][/COLOR]
[COLOR=#0000ff][B] Dim[/B][/COLOR] WorkRng [COLOR=#0000ff][B]As Range[/B][/COLOR]
[COLOR=#0000ff][B]Dim [/B][/COLOR]Ws [B][COLOR=#0000ff]As Worksheet
[/COLOR][/B]
[COLOR=#0000ff][B] On Error Resume Next[/B][/COLOR]
[B][COLOR=#0000ff] Set [/COLOR][/B]WorkRng = Application.Selection
[COLOR=#0000ff][B] Set[/B][/COLOR] WorkRng = Application.InputBox("Range", "My Title", WorkRng.Address, Type:=8)
[COLOR=#0000ff][B] Set [/B][/COLOR]Ws = Application.ActiveSheet
Application.ScreenUpdating = [COLOR=#0000ff][B]False[/B][/COLOR]
[B][COLOR=#0000ff] For Each[/COLOR][/B] Rng [COLOR=#0000ff][B]In[/B][/COLOR] WorkRng
[B][COLOR=#0000ff] With [/COLOR][/B]Ws.CheckBoxes.Add(Rng.Left, Rng.Top, Rng.Width, Rng.Height)
.Characters.Text = Rng.Value
[B][COLOR=#0000ff] End With
Next[/COLOR][/B]
WorkRng.ClearContents
WorkRng.Select
Application.ScreenUpdating = [COLOR=#0000ff][B]True[/B][/COLOR]
[B][COLOR=#0000ff] End Sub[/COLOR][/B]
Last edited: