Private Sub UserForm_Initialize()
Call CargarSis
Me.ListView1.ColumnHeaders.Clear
Me.ListView1.ListItems.Clear
With ListView1
.Gridlines = True
.CheckBoxes = True
.View = ivwReport
.FullRowSelect = True
.Visible = True
With .ColumnHeaders
.Clear
.Add , , "ID", 55
.Add , , "DEPARTAMENTO", 80, 0
.Add , , "MUNICIPIO", 80, 0
.Add , , "CODIGO MUNICIPAL", 55, 0
.Add , , "MES", 55, 0
.Add , , "AÑO", 55, 0
.Add , , "DOSIS", 80, 0
.Add , , "CANTIDAD", 55, 0
.Add , , "TOTAL DE DOSIS", 55, 0
End With
End With
Fila = 2
Do Until sheet1.cell(Fila, 3) = ""
Set LI = ListView1.ListItems.Add(Text:=sheet1.Cells(Fila, 1).Value)
LI.ListSubItems.Add Text:=sheet1.Cells(Fila, 2).Value
LI.ListSubItems.Add Text:=sheet1.Cells(Fila, 3).Value
LI.ListSubItems.Add Text:=sheet1.Cells(Fila, 4).Value
LI.ListSubItems.Add Text:=sheet1.Cells(Fila, 5).Value
LI.ListSubItems.Add Text:=sheet1.Cells(Fila, 6).Value
LI.ListSubItems.Add Text:=sheet1.Cells(Fila, 7).Value
LI.ListSubItems.Add Text:=sheet1.Cells(Fila, 8).Value
LI.ListSubItems.Add Text:=sheet1.Cells(Fila, 9).Value
Fila = Fila + 1
Loop
CodMunicipal.List = Worksheets("LISTAS").Range("B3:B4").Value
Departamento.List = Worksheets("LISTAS").Range("F3:F4").Value
Municipio.List = Worksheets("LISTAS").Range("D3:D4").Value
Dosis.List = Worksheets("LISTAS").Range("H3:H7").Value
Meses.List = Worksheets("LISTAS").Range("J3:J14").Value
Años.List = Worksheets("LISTAS").Range("L3:L4").Value
End Sub
Private Sub BtnGuardar_Click()
Dim fla As Integer
Dim Fnal As Integer
If Cantidad = "" Then
MsgBox "Debe Llenar el Esocojer cod municipio", vbCritical, "Aviso"
Exit Sub
End If
If lbl_info = "Edicion" Then
Call Modificado
Exit Sub
End If
fla = 2
Do While sheet1.Cells(fla, 1) <> ""
fla = fla + 1
Loop
Fnal = fla
With sheet1
.Cells(Fnal, 1) = ID.Value
.Cells(Fnal, 2) = Departamento.Value
.Cells(Fnal, 3) = Municipio.Value
.Cells(Fnal, 4) = Codigo_Municipal.Value
.Cells(Fnal, 5) = MES.Value
.Cells(Fnal, 6) = AÑO.Value
.Cells(Fnal, 7) = Dosis.Value
.Cells(Fnal, 8) = Cantidad.Value
.Cells(Fnal, 9) = TOTAL_DE_DOSIS.Value
End With
ActiveWorkbook.Save
MsgBox ("Informacion Guardada Con Exito!!"), vbInformation, "AEX"
Call Limpiar_campos
Call UserForm_Initialize
End Sub
Private Sub Limpiar_campos()
Dim objeto As Control
For Each objeto In Me.Controls
If TypeName(objeto) = "TextBox" Then
objeto.Text = ""
End If
Next objeto
Dim com As Object
For Each com In Me.Controls
If TypeOf com Is ComboBox Then
com = ""
End If
Next com
End Sub
Sub CargarSis()
lbl_info = "Registro"
Dim rLastValue As Range
Dim alpha As String
Dim numeric As Long
Set rLastValue = sheet1.Range("A1").End(xlDown)
alpha = "A"
numeric = Val(Replace(rLastValue, alpha, "")) + 1
ID = alpha & Format(numeric, "0000")
End Sub