Checkbox in Userform

lukael

New Member
Joined
Feb 9, 2014
Messages
6
Hello, I want to make this code working on my Userform1, which has checkbox in It. Userform1 is activated with macro1(Userform1.Show) on worksheet (button). Code works great with no Userfom :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim blnValue As Boolean
Dim shpCB As Shape
If Target.Count = 1 Then
  If Not Intersect(Target, Range("C4,C6")) Is Nothing Then
    blnValue = WorksheetFunction.CountA(Range("C4,C6")) = 2
    For Each shpCB In ActiveSheet.Shapes
      If shpCB.Name Like "Check*" Then
        shpCB.ControlFormat.Value = blnValue * -1
      End If
    Next shpCB
  End If
End If
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Try

Code:
Option Explicit




Private Sub UserForm_Initialize()
Me.CheckBox1 = application.WorksheetFunction.CountA(Sheet1.Range("E4,E6")) = 2
End Sub

Also, take a couple of minutes and read about crossposting
 
Upvote 0
Try

Code:
Option Explicit

Private Sub UserForm_Initialize()
Me.CheckBox1 = application.WorksheetFunction.CountA(Sheet1.Range("E4,E6")) = 2
End Sub

Also, take a couple of minutes and read about crossposting

Code works, but checkbox must be ticked only if both values are not blank, this one ticks if one is blank and other not. I was warned about crossposting, when I find solution I will post on all forum a solution and mark It as SOLVED.

many thanks royUK !
 
Upvote 0
Sorry, I've done mistake in typing cell numbers. Your code works great :)

THANK YOU 1000 TIMES !!!

just tell me how to mark this thread as Solved !!
 
Last edited:
Upvote 0
I don't think that you can mark a Thread solved here, I can only see Like or Share buttons in the post.
 
Upvote 0

Forum statistics

Threads
1,215,794
Messages
6,126,951
Members
449,350
Latest member
Sylvine

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