Dim ws As Worksheet
Dim i, Rc As Integer
Dim TBL As ListObject
Set ws = Sheets("sheet1")
On Error GoTo ErrorHandler
If Record.ComboBox1.Value = "" Then
MsgBox "please select"
Exit Sub
Else
Set TBL = ws.Range("Tbl").ListObject
If ws.Range("Tbl").Rows.Count = 1 And TB1.Value = 1 And H1.Value <> "" And H1.Value > 0 Then
TBL.ListRows.Add.Range(1, 1).Offset(0, 0).Value = DTPicker1.Value
TBL.ListRows.Add.Range(1, 1).Offset(0, 1).Value = ComboBox1.Value
TBL.ListRows.Add.Range(1, 1).Offset(0, 2).Value = H1.Value
If ComboBox2.Value <> "" Then TBL.ListRows.Add.Range(1, 1).Offset(0, 3).Value = CB1.Value & CB11.Value
Else
For i = 1 To 4
If Controls("TB" & i).Text <> "" And Controls("H" & i).Text <> "" Then
If CInt(Controls("TB" & i).Value) > 0 And CInt(Controls("H" & i).Value) > 0 Then
For Rc = 1 To CInt(Controls("TB" & i).Value)
TBL.ListRows.Add.Range(Rc, 1).Offset(0, 0) = DateAdd("d", Rc - 1, Controls("DTPicker" & i).Value)
TBL.ListRows.Add.Range(Rc, 1).Offset(0, 1) = ComboBox1.Value
TBL.ListRows.Add.Range(Rc, 1).Offset(0, 2) = Controls("H" & i).Value
If Controls("CB" & i).Value <> "" Then TBL.ListRows.Add.Range(Rc, 1).Offset(0, 3) = Controls("CB" & i).Value & Controls("CB" & i & i).Value
Next
End If
End If
Next i
End If
End If