Toggle text between cells

gasdude

New Member
Joined
Oct 22, 2018
Messages
3
This is my first ever post.

I have a spreadsheet that has a lot of check boxes in sets of two. When printed it is hard to tell what is checked. I have redone the sheet and replaced the check boxes with empty cells. I also have a VBA code that will enter a check mark when a cell is double clicked. Is it possible to make excel toggle between two cells when one is double clicked or delete the check mark in the other cell when the other is double clicked? Act like a check box. Below is the VBA code i am currently using.

Thanks in advance. This site has been a saving grace for me many times.
Gasdude

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("A17:A30, B17:B30, K17:K18, K20:K30, L17:L18, L20:L30, AF20:AF21, AF34:AF35")) Is Nothing Then
Application.EnableEvents = False
If ActiveCell.Value = ChrW(&H2713) Then
ActiveCell.ClearContents
Else
ActiveCell.Value = ChrW(&H2713)
End If
Cancel = True
End If
Application.EnableEvents = True
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
.
The best thing is to avoid Merged Cells. They only lead to more frustrations down the road.
 
Upvote 0
Hi & welcome to MrExcel.
What are the cells that you want to toggle?
 
Upvote 0
A17 B17, A18 B18, etc. I know this may be a log process to set them all up. Would be well worth it to me.

Thanks
 
Upvote 0
How about
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   Dim Offst As Long
   If Not Intersect(Target, Range("A17:A30, B17:B30, K17:K18, K20:K30, L17:L18, L20:L30")) Is Nothing Then
      Application.EnableEvents = False
      Select Case Target.Column
         Case 1, 11
            Offst = 1
         Case 2, 12
            Offst = -1
      End Select
      If Target.Value = ChrW(&H2713) Then
         Target.Offset(, Offst).Value = Target.Value
         Target.ClearContents
      Else
         Target.Offset(, Offst).Value = Target.Value
         Target.Value = ChrW(&H2713)
      End If
      Cancel = True
   End If
   Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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