Como adicionar registros con una macro
Hola recién inicio en esta página y veo que tu habilidad en excel es asombrosoza
Actualmente estoy realizando desde una macro, la selección de datos los cuales deben quedar almacenados en una hoja excel, el código utilizado para ello es el siguiente
Dim P As Integer
Dim internas As Integer
Dim externas As Integer
Dim satisfac As Integer
Dim Mmayor As Integer
Dim Mmenor As Integer
Dim actividad As Integer
Dim tiempoa As Integer
Dim Nestudio As Integer
Dim Tconfiar As Integer
Dim Edad As Integer
Dim Ecivil As Integer
Dim Pcargo As Integer
Dim Tvivien As Integer
Dim Ltelefono As Integer
Dim Menosd As Integer
Dim Masd As Integer
Dim eg As Double
Dim x As Double
Dim y As Double
Dim h As Double
Dim cupo As Long
Dim ed As Double
Dim a As Double
Private Sub CommandButton1_Click()
P = 0
cupo = 0
internas = 0
externas = 0
satisfac = 0
Mmayor = 0
Mmenor = 0
actividad = 0
tiempoa = 0
Nestudio = 0
Tconfiar = 0
Edad = 0
Ecivil = 0
Pcargo = 0
Tvivien = 0
Ltelefono = 0
Menosd = 0
Masd = 0
If ComboBox6.ListIndex = 0 Or ComboBox6.ListIndex = 9 Or ComboBox6.ListIndex = 15 Then
' Formula Boyaca
' experiencias internas
If TextBox5 < 0 Then
MsgBox ("Rectifique experiencias internas")
Else
If ((Val(TextBox5.Text)) < 1) Then
internas = 15
Else
If ((Val(TextBox5.Text)) <= 2) Then
internas = 25
Else
If ((Val(TextBox5.Text)) = 3) Then
internas = 40
Else
internas = 50
End If
End If
End If
End If
' Experiencias Externas
If TextBox4 < 0 Then
MsgBox ("Rectifique experiencias externas")
Else
If TextBox4.Text = 0 Then
externas = 8
Else
If TextBox4.Text <= 2 Then
externas = 16
Else
If TextBox4.Text = 3 Then
externas = 28
Else
externas = 40
End If
End If
End If
End If
'Experiencias satisfactorias
If (Val(TextBox5.Text) + Val(TextBox4.Text)) < Val(TextBox3.Text) Then
MsgBox ("Rectifique suma de experiencias internas y externas")
Else
If TextBox3 < 0 Then
MsgBox ("Rectifique experiencias satisfactorias")
Else
If TextBox3.Text = 0 Then
satisfac = 16
Else
If TextBox3.Text <= 2 Then
satisfac = 24
Else
If TextBox3.Text = 3 Then
satisfac = 42
Else
satisfac = 60
End If
End If
End If
End If
End If
'moras mayores
If TextBox1.Text < 0 Then
MsgBox ("Rectifique moras mayores")
Else
If TextBox1.Text = 0 And (TextBox5 + TextBox4 > 0) Then
Mmayor = 50
Else
If (TextBox1.Text = 0 And (TextBox5 + TextBox4 = 0)) Then
Mmayor = 25
Else
If TextBox1.Text >= 1 Then
Mmayor = -400
End If
End If
End If
End If
' Moras menores
If TextBox2.Text < 0 Then
MsgBox ("Rectifique moras menores")
Else
If TextBox2.Text = 0 And (TextBox5 + TextBox4 > 0) Then
Mmenor = 50
Else
If (TextBox2.Text = 0 And (TextBox5 + TextBox4 = 0)) Then
Mmenor = 25
Else
If TextBox2.Text = 1 Then
Mmenor = -150
Else
If TextBox2.Text >= 2 Then
Mmenor = -400
End If
End If
End If
End If
End If
'Tipo de actividad
If ComboBox1.ListIndex = 0 Then actividad = 80
If ComboBox1.ListIndex = 1 Then actividad = 160
If ComboBox1.ListIndex = 2 Then actividad = 15
' Tiempo en la actividad
If ComboBox2.ListIndex = 0 Then tiempoa = 10
If ComboBox2.ListIndex = 1 Then tiempoa = 40
If ComboBox2.ListIndex = 2 Then tiempoa = 30
'Nivel de estudios
If ComboBox5.ListIndex = 0 Then Nestudio = 3
If ComboBox5.ListIndex = 1 Then Nestudio = 14
If ComboBox5.ListIndex = 2 Then Nestudio = 18
If ComboBox5.ListIndex = 3 Then Nestudio = 21
If ComboBox5.ListIndex = 4 Then Nestudio = 27
'TIEMPO EN CONFIAR
If TextBox8.Text < 12 Then
Tconfiar = 10
Else
If TextBox8.Text < 36 Then
Tconfiar = 45
Else
Tconfiar = 100
End If
End If
'edad
If TextBox6.Text < 18 Then
MsgBox ("menor de edad")
Else
If TextBox6 < 25 Then
Edad = 10
Else
If TextBox6 <= 40 Then
Edad = 90
Else
If TextBox6 <= 50 Then
Edad = 40
Else
Edad = 65
End If
End If
End If
End If
' estado civil
If ComboBox3.ListIndex = 0 Then Ecivil = 50
If ComboBox3.ListIndex = 1 Then Ecivil = 35
If ComboBox3.ListIndex = 2 Then Ecivil = 30
If ComboBox3.ListIndex = 3 Then Ecivil = 45
If ComboBox3.ListIndex = 4 Then Ecivil = 40
'PERSONAS A CARGO
If TextBox7.Text = 0 Then
Pcargo = 12
Else
If TextBox7.Text <= 3 Then
Pcargo = 120
Else
Pcargo = 66
End If
End If
'Tipo de vivienda
If ComboBox4.ListIndex = 0 Then Tvivien = 70
If ComboBox4.ListIndex = 1 Then Tvivien = 55
If ComboBox4.ListIndex = 2 Then Tvivien = 39
If ComboBox4.ListIndex = 3 Then Tvivien = 23
If ComboBox4.ListIndex = 4 Then Tvivien = 7
'Lineas Telefonicas
If TextBox9.Text = 0 Then Ltelefono = 0
If TextBox9.Text = 1 Then Ltelefono = 10
If TextBox9.Text >= 2 Then Ltelefono = 20
'endeudamiento
If CheckBox1.Value = True Then
TextBox10.Text = 0.15 * TextBox26.Text * ((TextBox7.Text / 2) + 1)
eg = (Val(TextBox10.Text) + Val(TextBox11.Text) + Val(TextBox12.Text) + (Val(TextBox13.Text) / 2))
ed = eg / Val(TextBox14.Text)
TextBox16.Text = Format(ed, "0.00%")
TextBox15.Text = Val(TextBox14.Text) - eg
Else
TextBox10.Text = 0.15 * (Val(TextBox26.Text)) * (Val(TextBox7) + 1)
eg = (Val(TextBox10.Text) + Val(TextBox11.Text) + Val(TextBox12.Text) + (Val(TextBox13.Text)))
ed = eg / Val(TextBox14.Text)
TextBox16.Text = Format(ed, "0.00%")
TextBox15.Text = Val(TextBox14.Text) - eg
End If
' Menos de 2 salarios de ingreso
If TextBox14.Text < 2 * TextBox26.Text Then
If ed < 0.6 Then
Menosd = 160
Else
If ed <= 0.7 Then
Menosd = 115
Else
If ed <= 0.8 Then
Menosd = 60
Else
If ed <= 0.9 Then
Menosd = 0
Else
Menosd = -350
End If
End If
End If
End If
Else
' Mas de 2 salarios de ingreso
If ed < 0.5 Then
Masd = 160
Else
If ed <= 0.6 Then
Masd = 110
Else
If ed <= 0.7 Then
Masd = 60
Else
If ed <= 0.8 Then
Masd = 0
Else
Masd = -350
End If
End If
End If
End If
End If
End If
Private Sub CommandButton2_Click()
Dim dato
dato = 2
Hoja3.Select
Range("A1") = internas
Range("B1") =...
Actualmente estoy realizando desde una macro, la selección de datos los cuales deben quedar almacenados en una hoja excel, el código utilizado para ello es el siguiente
Dim P As Integer
Dim internas As Integer
Dim externas As Integer
Dim satisfac As Integer
Dim Mmayor As Integer
Dim Mmenor As Integer
Dim actividad As Integer
Dim tiempoa As Integer
Dim Nestudio As Integer
Dim Tconfiar As Integer
Dim Edad As Integer
Dim Ecivil As Integer
Dim Pcargo As Integer
Dim Tvivien As Integer
Dim Ltelefono As Integer
Dim Menosd As Integer
Dim Masd As Integer
Dim eg As Double
Dim x As Double
Dim y As Double
Dim h As Double
Dim cupo As Long
Dim ed As Double
Dim a As Double
Private Sub CommandButton1_Click()
P = 0
cupo = 0
internas = 0
externas = 0
satisfac = 0
Mmayor = 0
Mmenor = 0
actividad = 0
tiempoa = 0
Nestudio = 0
Tconfiar = 0
Edad = 0
Ecivil = 0
Pcargo = 0
Tvivien = 0
Ltelefono = 0
Menosd = 0
Masd = 0
If ComboBox6.ListIndex = 0 Or ComboBox6.ListIndex = 9 Or ComboBox6.ListIndex = 15 Then
' Formula Boyaca
' experiencias internas
If TextBox5 < 0 Then
MsgBox ("Rectifique experiencias internas")
Else
If ((Val(TextBox5.Text)) < 1) Then
internas = 15
Else
If ((Val(TextBox5.Text)) <= 2) Then
internas = 25
Else
If ((Val(TextBox5.Text)) = 3) Then
internas = 40
Else
internas = 50
End If
End If
End If
End If
' Experiencias Externas
If TextBox4 < 0 Then
MsgBox ("Rectifique experiencias externas")
Else
If TextBox4.Text = 0 Then
externas = 8
Else
If TextBox4.Text <= 2 Then
externas = 16
Else
If TextBox4.Text = 3 Then
externas = 28
Else
externas = 40
End If
End If
End If
End If
'Experiencias satisfactorias
If (Val(TextBox5.Text) + Val(TextBox4.Text)) < Val(TextBox3.Text) Then
MsgBox ("Rectifique suma de experiencias internas y externas")
Else
If TextBox3 < 0 Then
MsgBox ("Rectifique experiencias satisfactorias")
Else
If TextBox3.Text = 0 Then
satisfac = 16
Else
If TextBox3.Text <= 2 Then
satisfac = 24
Else
If TextBox3.Text = 3 Then
satisfac = 42
Else
satisfac = 60
End If
End If
End If
End If
End If
'moras mayores
If TextBox1.Text < 0 Then
MsgBox ("Rectifique moras mayores")
Else
If TextBox1.Text = 0 And (TextBox5 + TextBox4 > 0) Then
Mmayor = 50
Else
If (TextBox1.Text = 0 And (TextBox5 + TextBox4 = 0)) Then
Mmayor = 25
Else
If TextBox1.Text >= 1 Then
Mmayor = -400
End If
End If
End If
End If
' Moras menores
If TextBox2.Text < 0 Then
MsgBox ("Rectifique moras menores")
Else
If TextBox2.Text = 0 And (TextBox5 + TextBox4 > 0) Then
Mmenor = 50
Else
If (TextBox2.Text = 0 And (TextBox5 + TextBox4 = 0)) Then
Mmenor = 25
Else
If TextBox2.Text = 1 Then
Mmenor = -150
Else
If TextBox2.Text >= 2 Then
Mmenor = -400
End If
End If
End If
End If
End If
'Tipo de actividad
If ComboBox1.ListIndex = 0 Then actividad = 80
If ComboBox1.ListIndex = 1 Then actividad = 160
If ComboBox1.ListIndex = 2 Then actividad = 15
' Tiempo en la actividad
If ComboBox2.ListIndex = 0 Then tiempoa = 10
If ComboBox2.ListIndex = 1 Then tiempoa = 40
If ComboBox2.ListIndex = 2 Then tiempoa = 30
'Nivel de estudios
If ComboBox5.ListIndex = 0 Then Nestudio = 3
If ComboBox5.ListIndex = 1 Then Nestudio = 14
If ComboBox5.ListIndex = 2 Then Nestudio = 18
If ComboBox5.ListIndex = 3 Then Nestudio = 21
If ComboBox5.ListIndex = 4 Then Nestudio = 27
'TIEMPO EN CONFIAR
If TextBox8.Text < 12 Then
Tconfiar = 10
Else
If TextBox8.Text < 36 Then
Tconfiar = 45
Else
Tconfiar = 100
End If
End If
'edad
If TextBox6.Text < 18 Then
MsgBox ("menor de edad")
Else
If TextBox6 < 25 Then
Edad = 10
Else
If TextBox6 <= 40 Then
Edad = 90
Else
If TextBox6 <= 50 Then
Edad = 40
Else
Edad = 65
End If
End If
End If
End If
' estado civil
If ComboBox3.ListIndex = 0 Then Ecivil = 50
If ComboBox3.ListIndex = 1 Then Ecivil = 35
If ComboBox3.ListIndex = 2 Then Ecivil = 30
If ComboBox3.ListIndex = 3 Then Ecivil = 45
If ComboBox3.ListIndex = 4 Then Ecivil = 40
'PERSONAS A CARGO
If TextBox7.Text = 0 Then
Pcargo = 12
Else
If TextBox7.Text <= 3 Then
Pcargo = 120
Else
Pcargo = 66
End If
End If
'Tipo de vivienda
If ComboBox4.ListIndex = 0 Then Tvivien = 70
If ComboBox4.ListIndex = 1 Then Tvivien = 55
If ComboBox4.ListIndex = 2 Then Tvivien = 39
If ComboBox4.ListIndex = 3 Then Tvivien = 23
If ComboBox4.ListIndex = 4 Then Tvivien = 7
'Lineas Telefonicas
If TextBox9.Text = 0 Then Ltelefono = 0
If TextBox9.Text = 1 Then Ltelefono = 10
If TextBox9.Text >= 2 Then Ltelefono = 20
'endeudamiento
If CheckBox1.Value = True Then
TextBox10.Text = 0.15 * TextBox26.Text * ((TextBox7.Text / 2) + 1)
eg = (Val(TextBox10.Text) + Val(TextBox11.Text) + Val(TextBox12.Text) + (Val(TextBox13.Text) / 2))
ed = eg / Val(TextBox14.Text)
TextBox16.Text = Format(ed, "0.00%")
TextBox15.Text = Val(TextBox14.Text) - eg
Else
TextBox10.Text = 0.15 * (Val(TextBox26.Text)) * (Val(TextBox7) + 1)
eg = (Val(TextBox10.Text) + Val(TextBox11.Text) + Val(TextBox12.Text) + (Val(TextBox13.Text)))
ed = eg / Val(TextBox14.Text)
TextBox16.Text = Format(ed, "0.00%")
TextBox15.Text = Val(TextBox14.Text) - eg
End If
' Menos de 2 salarios de ingreso
If TextBox14.Text < 2 * TextBox26.Text Then
If ed < 0.6 Then
Menosd = 160
Else
If ed <= 0.7 Then
Menosd = 115
Else
If ed <= 0.8 Then
Menosd = 60
Else
If ed <= 0.9 Then
Menosd = 0
Else
Menosd = -350
End If
End If
End If
End If
Else
' Mas de 2 salarios de ingreso
If ed < 0.5 Then
Masd = 160
Else
If ed <= 0.6 Then
Masd = 110
Else
If ed <= 0.7 Then
Masd = 60
Else
If ed <= 0.8 Then
Masd = 0
Else
Masd = -350
End If
End If
End If
End If
End If
End If
Private Sub CommandButton2_Click()
Dim dato
dato = 2
Hoja3.Select
Range("A1") = internas
Range("B1") =...
1 Respuesta
Respuesta de fejoal
1