Excel - Error de Combobox en Userform

 
Vista:

Error de Combobox en Userform

Publicado por fmoreno (1 intervención) el 06/07/2014 15:20:08
Hola chicos, mi duda es la siguiente, tengo un Userform preparado para la inserción de una serie de datos, con un combobox y 4 texbox, desde los que inserto los datos a la hoja, y con el combobox los llamo al userform para modificar, añadir y borrar, etc etc. La cuestion es que funciona perfectamente y tengo otros userforms que funcionan con la misma estructura, pero este en particular cuando lanzo el userform, excel no me deja escribir en el combobox, lo curioso es que en los texbox si puedo y ademas cuando agrego los datos a la hoja puego puedo recogerlos y modificarlos perfectamente, el caso es que NO me deja escribir en el combobox. Acá les muestro el codigo del userform:

Private Sub cmd_registrar2_inv_Click()

Sheets("INVOICE").Activate

Dim fINV2 As Integer
fINV2 = nINV2(cbo_ref_inv.Text)

If fINV2 = 0 Then
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Activate ' si el registro no existe, se va al final.
Loop
Else
Cells(fINV2, 3).Select ' cuando ya existe el registro, cumple esta condición.
End If

'Aqui es cuando agregamos o modificamos el registro
Application.ScreenUpdating = False
ActiveCell = cbo_ref_inv
Sheets("INVOICE").Range("D54").Value = txt_issue_inv
Sheets("INVOICE").Range("C38:G38").Value = ("Purchase Order Ref: " & cbo_ref_inv)
Sheets("INVOICE").Range("C39:G39").Value = ("Date of Issue: " & txt_issue_inv)
Sheets("INVOICE").Range("K37").Value = txt_discount_inv
Sheets("INVOICE").Range("K38").Value = txt_other_inv
Sheets("INVOICE").Range("K39").Value = txt_sh_inv

Application.ScreenUpdating = True

LimpiarFormulario2

MsgBox "Your Special Data has been included in your Invoice.", vbInformation + vbOKOnly
cbo_ref_inv.SetFocus

End Sub
Private Sub cmd_eliminar2_inv_Click()
Dim fINV2 As Integer
fINV2 = nINV2(cbo_ref_inv.Text)

If fINV2 = 0 Then
MsgBox "The Special Data selected does not exist", vbInformation + vbOKOnly
cbo_ref_inv.SetFocus
Exit Sub
End If

If MsgBox("Are you sure you want to delete this Special Data?", vbQuestion + vbYesNo) = vbYes Then

Cells(fINV2, 3).Select

Sheets("INVOICE").Range("C54").ClearContents
Sheets("INVOICE").Range("D54").ClearContents
Sheets("INVOICE").Range("C38:G38").ClearContents
Sheets("INVOICE").Range("C39:G39").ClearContents
Sheets("INVOICE").Range("K37").ClearContents
Sheets("INVOICE").Range("K38").ClearContents
Sheets("INVOICE").Range("K39").ClearContents

LimpiarFormulario2

MsgBox "Special Data Deleted", vbInformation + vbOKOnly
cbo_ref_inv.SetFocus

End If

End Sub

Private Sub cbo_ref_inv_Change()

On Error Resume Next


If nINV2(cbo_ref_inv.Text) <> 0 Then

Sheets("INVOICE").Activate

Cells(fINV2, 3).Select
txt_issue_inv = Sheets("INVOICE").Range("D54")
txt_discount_inv = Sheets("INVOICE").Range("K37")
txt_other_inv = Sheets("INVOICE").Range("K38")
txt_sh_inv = Sheets("INVOICE").Range("K39")

Else
cbo_ref_inv = ""
txt_issue_inv = ""
txt_discount_inv = ""
txt_other_inv = ""
txt_sh_inv = ""

End If

End Sub
Private Sub cbo_ref_inv_Enter()
CargarLista2
End Sub
Sub CargarLista2()
cbo_ref_inv.Clear

Sheets("INVOICE").Select
Range("C54").Select
Do While Not IsEmpty(ActiveCell)
cbo_ref_inv.AddItem ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Loop

End Sub

Sub LimpiarFormulario2()
CargarLista2

cbo_ref_inv = ""
txt_issue_inv = ""
txt_discount_inv = ""
txt_other_inv = ""
txt_sh_inv = ""

End Sub

Tambien tengo definido en un modulo el siguiente codigo para lanzar el userform y definir una variable:

Option Explicit
Sub registrar2_inv()
Load UserForm5
Sheets("INVOICE").Activate
UserForm5.Show
End Sub

Function nINV2(nombre As String) As Integer
Application.ScreenUpdating = False

Sheets("INVOICE").Activate
Range("C54").Activate


nINV2 = 0

Do While Not IsEmpty(ActiveCell)
If nombre = ActiveCell Then
nINV2 = ActiveCell.Row
End If
ActiveCell.Offset(1, 0).Select
Loop


Application.ScreenUpdating = True

End Function


Como les dije funciona perfectamente, pero el que no me deje escribir en el combobox creo que es un error de definición que por mas que los busco no lo detecto. Si estoy equivocado por favor echarme un cable.

Gracias de antemano
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
sin imagen de perfil

Error de Combobox en Userform

Publicado por JUAN (62 intervenciones) el 07/07/2014 20:43:42
puedes enviar el excel para revisarlo?
saludos
jpp
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar