Hi
What im trying to achieve:
I have a multiple checkboxes linked to different cells and need to do somethin dependent on the linked cells value (True, False or vbNullstring)
Private Sub CommandButton2_Click()
Dim CurCell As Object
Dim s As Integer
Dim h As Integer
Dim v As Integer
Dim g As Integer
s = Left(ComboBox1.Value, 2)
h = Right(ComboBox1.Value, 2)
v = Left(ComboBox2.Value, 2)
g = Right(ComboBox2.Value, 2)
MyHours = TimeSerial(s + v, h + g, 0)
For Each CurCell In Range("A2:K17")
If CurCell.Value = True And CurCell.Offset(-1, -1).Value = "" Then ' if checked and linked cell offset is empty then result
CurCell.Offset(-1, -1).Value = ComboBox3 & ": " & ComboBox1.Value & "-" & Format(MyHours, "hh:mm")
ElseIf CurCell.Value = True And CurCell.Offset(-1, -1).Value > "" Then ' if checked and linked cell not empty then append result
CurCell.Offset(-1, -1).Value = CurCell.Offset(-1, -1).Value & Chr(10) & ComboBox3 & ": " & ComboBox1.Value & "-" & Format(MyHours, "hh:mm")
Else
' do nothing
End If
Next
ActiveSheet.CheckBoxes.Value = False
Unload Me
End Sub
*Edit: The part that isn't working is the If statement
It work ok when i only have this code
For Each CurCell In Range("A2:K17")
If CurCell.Value = True Then CurCell.Offset(-1, -1).Value = ComboBox3 & ": " & ComboBox1.Value & "-" & Format(MyHours, "hh:mm")
Next
But then i loose the append functiomality when there is allready data in curCell.Offset(-1,-1)
Hope for some good help
Steffen Thomsen
Bookmarks