error 1004 error en el metodo "Range" de objeto "_Global"
Publicado por Rosy serna (1 intervención) el 14/05/2014 21:31:49
me aparece este error en mi sistema, lo que requiero hacer es dar de alta un cliente, pero si ya existe el num. de cliente que no lo agregue y deje en blanco e indicar que ya existe, pero cuando es un cliente nuevo al momento de que ya va insertar la información me marca este error y no se que es lo que estoy haciendo mal me pueden ayudar porfis. este es mi código...
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Private Sub CommandButton1_Click()
Dim i As Integer
Dim idBusca As String
Dim fila As Long
Application.ScreenUpdating = False
Dim Num_Cliente As Range
Sheets("flota").Select
Range("B2").Select
Selection.EntireRow.Insert
Set Num_Cliente = Cells.Find(What:=TextCliente.Text, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False):
fila = 2
TextCliente = TextCliente.Value
Do While idBusca <> TextCliente
fila = fila + 1
idBusca = Range("B" & fila).Value
Loop
If TextCliente = idBusca Then
MsgBox "NUMERO DE CLIENTE YA EXISTE NO SE PUEDE REPETIR, INDICA UN NUEVO NÚMERO", _
vbInformation + vbOKOnly, "REGISTRO DE CLIENTES"
Worksheets("flota").Rows(11).Delete
TextStatus.Text = Empty
TextCliente.Text = ""
TextFechaAlta = Date
TextMMembresia.Text = Empty
TextNombre.Text = Empty
TextCalle.Text = Empty
TextColonia.Text = Empty
TextCP.Text = Empty
TextTel.Text = Empty
TextMail.Text = Empty
TextPass.Text = Empty
TextCliente.SetFocus
Exit Sub
End If
If Me.TextStatus.Value = "" Then MsgBox ("Campo STATUS no puede estar vacio"): _
Exit Sub
If Me.TextCliente.Text = "" Then MsgBox ("Campo Nº DE CLIENTE no puede estar vacio"): _
Exit Sub
If Me.TextMMembresia.Value = "" Then MsgBox ("Campo MEMBRESIA no puede estar vacio"): _
Exit Sub
If Me.TextNombre.Text = "" Then MsgBox ("Campo NOMBRE no puede estar vacio"): Exit Sub
If Me.TextCalle.Text = "" Then MsgBox ("Campo CALLE Y NUMERO no puede estar vacio"): _
Exit Sub
If Me.TextColonia.Text = "" Then MsgBox ("Campo COLONIA no puede estar vacio"): _
Exit Sub
If Me.TextCP.Text = "" Then MsgBox ("Campo CODIGO POSTAL no puede estar vacio"): _
Exit Sub
If Me.TextTel.Text = "" Then MsgBox ("Campo TELEFONO no puede estar vacio"): Exit Sub
If Me.TextMail.Text = "" Then MsgBox ("Campo MAIL no puede estar vacio"): Exit Sub
If Me.TextPass.Text = "" Then MsgBox ("Campo PASSWORD no puede estar vacio"): Exit Sub
Hoja2.Select
'se asigna a la variable i el valor de la última fila con datos +1
'con Range("A" & Rows.Count).End(xlUp).Row + 1, es decir,
'se va hasta la última fila de la columna "A"(1048576 en la versión 2007
'o 65536 en la versión 2003) y de allí se sube con(xlUp)hasta la primera fila
'con datos, luego se le suma una para obtener la fila donde
'se deben agregar los ítems
i = Range("A" & Rows.Count).End(xlUp).Row + 1
'se agregan los nuevos datos
'Range("A" & i).Value = TextMModelo.Text
Range("A" & i).Value = TextStatus.Value
Range("B" & i).Value = TextCliente.Text
Range("C" & i).Value = TextFechaAlta
Range("D" & i).Value = TextMMembresia.Value
Range("E" & i).Value = TextNombre.Text
Range("F" & i).Value = TextCalle.Text
Range("G" & i).Value = TextColonia.Text
Range("H" & i).Value = TextCP.Text
Range("i" & i).Value = TextTel.Text
Range("J" & i).Value = TextMail.Text
Range("K" & i).Value = TextPass.Text
'mensaje de advertencia
If MsgBox("¿VERIFICO QUE TODOS LOS DATOS ESTAN CORRECTOS?", vbExclamation + vbYesNo) = _
vbYes Then
'Después de verificar que todos los datos están correctos
'se vacían los TextBox
TextStatus.Text = ""
TextCliente.Text = ""
TextFechaAlta.Text = ""
TextMMembresia.Text = ""
TextNombre.Text = ""
TextCalle.Text = ""
TextColonia.Text = ""
TextCP.Text = ""
TextTel.Text = ""
TextMail.Text = ""
TextPass.Text = ""
If MsgBox("¿DESEA AGREGAR OTRO CLIENTE?", vbExclamation + vbYesNo) = _
vbYes Then
TextFechaAlta = Date
TextCliente.SetFocus
End If
End If
'se selecciona la hoja 1 para que el formulario
'aparezca en ella
Hoja1.Select
'se selecciona el rango B4 para ocultrlo detrás de un botón
Range("B4").Select
End Sub
Valora esta pregunta


0