Hi ,
See the attached file.
Narayan
Hi ,I am wondering if it is possible to do so without manually assigning the codes to each check boxes. As it would be a tedious job mannully assign codes to some 100 check boxes.
I mean to say that i want to run the codes as we click on each individual check boxes.Hi ,
Can you explain what this means ?
What code is being manually assigned to each check box ?
Narayan
Sub fst()
Dim s As Shape, r As Range, lr As Long
ActiveSheet.Protect UserInterfaceOnly:=True, DrawingObjects:=True, _
Contents:=True, Scenarios:=True
With ActiveSheet
Set s = .Shapes(Application.Caller)
If Left(s.Name, 9) <> "Check Box" Then Exit Sub
lr = s.TopLeftCell.Row
Set r = .Range(.Cells(lr, "A"), .Cells(lr, s.TopLeftCell.Column - 1))
r.Font.Strikethrough = s.ControlFormat.Value = Checked
End With
End Sub
Hi ,TIP: Hold control key down and right click each control and then Assign the one macro.
'Set r = .Range(.Cells(lr, "A"), .Cells(lr, s.TopLeftCell.Column - 1))
Set r = Union(.Cells(lr, "A"), .Cells(lr, "D"))
Wow Kenneth, i was not aware of the "union" syntax. Thanks for letting me know about this.Code:'Set r = .Range(.Cells(lr, "A"), .Cells(lr, s.TopLeftCell.Column - 1)) Set r = Union(.Cells(lr, "A"), .Cells(lr, "D"))
Yes. What I would do is use a Worksheet Change Event.
Normally, one might run a batch macro to fix the missing ones and then use the Change event to maintain the status as they change in value. Of course if more than one of the target cells, say columns A or C change in value, it would act on the change for each. If coded this way, Intersect() would act on each of the targeted cell rows. The usual method to code Change events is to skip it if more than one cell in the target range was changed. Doing it for all, avoids the need for a batch fix method as a cut/paste would trigger what you want to fix things up. While a little more work, adding a loop to act on multiple target changed cells all at once (cut/paste, delete) is usually best.
I wasn't sure about the "-" part of your other thread. A filter obviously hides the rows. A AND filter for the "-" might suit your needs. I would have to read the thread more closely. I will check back on that thread tonight.
I will check back on that thread tonight.
My suggestion already does this and from what I remember Narayan's too.Hi Friends,
I was wondering, if instead of all striking all the cell in the row, can we strike through cells only in column A and D.
'Set r = Range("A:D").Rows(s.TopLeftCell.Row)
Set r = Intersect(Union(.Columns("A"), .Columns("D")), .Rows(s.TopLeftCell.Row))
Public Sub StrikeThroughData()
Dim chkbox As Shape
Set chkbox = Shapes(Application.Caller)
Rows(chkbox.TopLeftCell.Row).range("A1,D1").Font.Strikethrough = chkbox.ControlFormat.Value = Checked
End Sub
'Set chkbox = Shapes(Application.Caller)
Set chkbox = activesheet.Shapes(Application.Caller)