Excel - Error al Grabar

 
Vista:

Error al Grabar

Publicado por Javier (2 intervenciones) el 29/10/2016 18:31:20
Buenas Tardes, he realizado dos form (frmIngresoClientes y FrmBUscarClientes) -VB para Excel. Si inicio con el FrmIngresoClientes el codigo GUARDAR funciona, graba en hoja excel pero si inicio el FrmBuscarCliente y desde ahi llamo al FrmIngresoCliente el codigo GUARDAR me arroja un error 'Value' de obeto 'Range' y excel se reinicia. favor podrian indicarme cual es mi error.

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
Dim ws As Worksheet
Dim i As Integer
Dim Ruc As String
 
Set ws = ThisWorkbook.ActiveSheet
ws.Activate
 
Ruc = txtRuc.Text
 
If Len(Trim(Ruc)) = 11 And IsNumeric(Ruc) And txtRazonSocial.Text <> "" And txtNombreComercial.Text <> "" Then
 
    'ActiveWorkbook.Sheets.Select
    Sheets("clientes").Select
 
    Range("B2").Select
        Do While ActiveCell <> Empty
            If CStr(ActiveCell) = txtRuc Then
            MsgBox "RUC ya esta registrado", vbCritical, "Alerta"
            GoTo Termina
            End If
            ActiveCell.Offset(1, 0).Select
        Loop
 
 
    i = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count
 
    Cells(i + 1, 1).Value = i
    Cells(i + 1, 2).Value = txtRuc.Value
    Cells(i + 1, 3).Value = txtRazonSocial.Value
    Cells(i + 1, 4).Value = txtNombreComercial.Value
    Cells(i + 1, 5).Value = txtDireccion.Value
    Cells(i + 1, 6).Value = txtContacto.Value
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder