vba - excel macro para insertar nuevos datos a una planilla en el lugar correcto
Publicado por AFB (6 intervenciones) el 11/05/2020 18:25:12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
' acá les paso el código del ejemplo Y adjunto a este código una workbook de excel, con una sola hoja de ejemplo en la cual agregar datos al final de la lista, según su formato.
' -----------------------------------
Dim Celda() As CellFormat
Dim Hoja_n As Workbook
Dim Celda_fin As String
Dim Celda_inicio As String
Dim R As Range
Sub Saltar_Celdas_Llenas(Hoja_n, Celda_inicio, Celda_fin)
Application.Workbooks("tabla02").Worksheet(Hoja_n).Select
Set Celda(0) = Celda_inicio
Set Celda(1) = Celda_fin
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Activate
Loop
End Sub
Sub Ejemplo_33()
Dim Nombre As String
Dim Ciudad As String
Dim Edad As Integer
Dim Fecha As Date
Dim Mas_datos As Integer
Dim Nuevo_Nombre As String
Call Saltar_Celdas_Llenas(Hoja_n, Celda_inicio, Celda_fin)
' ----------------
Do
Nombre = InputBox("Entre el Nombre (Return para Terminar) : ", "Nombre")
Ciudad = InputBox("Entre la Ciudad : ", "Ciudad")
Edad = Val(InputBox("Entre la Edad : ", "Edad"))
Fecha = CDate(InputBox("Entre la Fecha : ", "Fecha"))
With ActiveCell
.Value = Nombre
.Offset(0, 1).Value = Ciudad
.Offset(0, 2).Value = Edad
.Offset(0, 3).Value = Fecha
End With
ActiveCell.Offset(1, 0).Activate
Mas_datos = MsgBox("Otro registro ?", vbYesNo + vbQuestion, "Entrada de datos")
Loop While Mas_datos = vbYes
ActiveWorkbook.Save
End Sub
- tabla02.xlsx.zip(63,0 KB)
Valora esta pregunta


0