H o l a:
Te anexo la macro actualizada para rellenar la tienda
Private Sub CommandButton1_Click()
'Por.Dante Amor
Dim nuevos As New Collection
Set h1 = Sheets("personal")
Set h2 = Sheets("BlockHora")
Set b = h1.Columns("c").Find(ComboBox2, lookat:=xlWhole)
If Not b Is Nothing Then
tienda = h1.Cells(b.Row, "G")
h1.Cells(b.Row, "h") = LUNES.Text
h1.Cells(b.Row, "i") = MARTES.Text
h1.Cells(b.Row, "j") = MIERCOLES.Text
h1.Cells(b.Row, "k") = JUEVES.Text
h1.Cells(b.Row, "l") = VIERNES.Text
h1.Cells(b.Row, "m") = SABADO.Text
h1.Cells(b.Row, "n") = DOMINGO.Text
End If
'
colent = 4
colsal = 5
ent = 1
sal = 2
n = 0
For i = 12 To 18
existe = False
Set r = h2.Columns("B")
Set b = r.Find(ComboBox2, lookat:=xlWhole)
If Not b Is Nothing Then
ncell = b.Address
Do
'detalle
If Controls("ComboBox" & i) = h2.Cells(b.Row, "A") Then
fila = b.Row
existe = True
Exit Do
Else
h2.Cells(b.Row, colent) = Controls("ComboBox" & i)
h2.Cells(b.Row, colsal) = Controls("ComboBox" & i)
End If
Set b = r.FindNext(b)
Loop While Not b Is Nothing And b.Address <> ncell
End If
'
If existe Then
'Modificar
hora = Hour(Controls("TextBox" & ent))
minuto = Minute(Controls("TextBox" & ent))
h2.Cells(fila, colent) = TimeSerial(hora, minuto, 0)
hora = Hour(Controls("TextBox" & sal))
minuto = Minute(Controls("TextBox" & sal))
h2.Cells(fila, colsal) = TimeSerial(hora, minuto, 0)
Else
'agregar
u = h2.Range("A" & Rows.Count).End(xlUp).Row + 1
h2.Cells(u, "A") = Controls("ComboBox" & i)
h2.Cells(u, "B") = ComboBox2
h2.Cells(u, "C") = ComboBox10
hora = Hour(Controls("TextBox" & ent))
minuto = Minute(Controls("TextBox" & ent))
h2.Cells(u, colent) = TimeSerial(hora, minuto, 0)
hora = Hour(Controls("TextBox" & sal))
minuto = Minute(Controls("TextBox" & sal))
h2.Cells(u, colsal) = TimeSerial(hora, minuto, 0)
nuevos.Add u
End If
colent = colent + 2
colsal = colsal + 2
ent = ent + 2
sal = sal + 2
Next
'
'Rellenar tiendas
colent = 4
colsal = 5
ent = 1
sal = 2
For i = 1 To nuevos.Count
fila = nuevos(i)
For j = 4 To 16 Step 2
If h2.Cells(fila, j) = "0" Or h2.Cells(fila, j) = "" Then
existe = False
Set r = h2.Columns("B")
Set b = r.Find(ComboBox2, lookat:=xlWhole)
If Not b Is Nothing Then
ncell = b.Address
Do
If b.Row <> fila And h2.Cells(b.Row, j) > 0 And _
Left(h2.Cells(b.Row, j), 1) <> "T" Then
h2.Cells(fila, j) = h2.Cells(b.Row, "A")
h2.Cells(fila, j + 1) = h2.Cells(b.Row, "A")
Exit Do
End If
Set b = r.FindNext(b)
Loop While Not b Is Nothing And b.Address <> ncell
End If
End If
Next
Next
'
MsgBox "Se cargo la informacion", vbApplicationModal, "SE CARGO"
End Sub
‘
S a l u d o s . D a n t e A m o r. Recuerda valorar la respuesta. G r a c i a s