Convert to Wingdings Checkboxes

Ciccio86

New Member
Joined
Feb 3, 2023
Messages
27
Office Version
  1. 365
Platform
  1. Windows
Hi, im tryng to convert my code from ActiveX Checkboxes to Wingdings "Checkboxes"

Thats the code im using for Wingdings
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  Dim i As Range
  Set i = Intersect(Target, Range("Checkboxes"))
        If Prev(i) = "PrevNo" Then
            Exit Sub
        End If
  If Not i Is Nothing Then
    Cancel = True
    Application.EnableEvents = False
    If i.Value = "þ" Then
      i.Value = "¨"
      i.Offset(0, 1).Value = "No"
      'ToggleLock i.Row, False
    Else
      i.Value = "þ"
      'ToggleLock i.Row, True
      i.Offset(0, 1).Value = "Yes"
    End If
    Application.EnableEvents = True
   
  End If

And this is the code that im tryng to convert

VBA Code:
Function Prev(chk As OLEObject)
Application.ScreenUpdating = False

Dim PrevValue As Variant
 
    If TypeName(chk.Object) = "CheckBox" Then
    PrevValue = chk.TopLeftCell.Offset(-1, 0).Value
    If PrevValue = "0" Or IsEmpty(PrevValue) Then
        chk.TopLeftCell.Offset(0, 0).Value = "Not Checked"
        chk.Object = False
        MsgBox "Not checked", vbExclamation, "WARNING"
        Prev = "PrevNo"
    Else
        chk.TopLeftCell.Offset(0, 0).Value = "Checked"
        chk.TopLeftCell.Offset(1, -2).Select
        End If
    End If

Application.ScreenUpdating = True
End Function

That's my failed attempt with error

Type mismatch (Error 13)​

On string
VBA Code:
If TypeName(Range("Checkboxes")) Then

VBA Code:
Function Prev(i As Range)
Application.ScreenUpdating = False

Dim PrevValue As Variant
Set i = Range("Checkboxes")
 
    If TypeName(Range("Checkboxes")) Then
    PrevValue = i.Offset(-1, 0).Value
    If PrevValue = "0" Or IsEmpty(PrevValue) Then
        i.Offset(0, 0).Value = "Not Checked"
        MsgBox "Not checked", vbExclamation, "WARNING"
        Prev = "PrevNo"
    Else
        i.Offset(0, 0).Value = "Checked"
        i.TopLeftCell.Offset(1, -2).Select
        End If
    End If

Application.ScreenUpdating = True
End Function
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try adding a sheet reference
VBA Code:
Set i = Worksheets("YourWorksheetName").Range("Checkboxes")
 
Upvote 0
Try adding a sheet reference
VBA Code:
Set i = Worksheets("YourWorksheetName").Range("Checkboxes")
Same error on
VBA Code:
 If TypeName(Range("Checkboxes")) Then

Type mismatch (Error 13)​


VBA Code:
Function Prev(i As Range)
Application.ScreenUpdating = False

Dim PrevValue As Variant
Set i = Worksheets("CAP").Range("Checkboxes")
 
   If TypeName(Range("Checkboxes")) Then
    PrevValue = i.Offset(-1, 0).Value
    If PrevValue = "0" Or IsEmpty(PrevValue) Then
        i.Offset(0, -1).Value = "Not Checked"
        MsgBox "Not checked", vbExclamation, "WARNING"
        Prev = "PrevNo"
    Else
        i.Offset(0, 1).Value = "Checked"
        i.Offset(1, -2).Select
        End If
    End If

Application.ScreenUpdating = True
End Function
 
Upvote 0

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top