Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

la modificacion de datos no me esta funcioando bien

publicado

hola estoy haciendo un formulario para modificar datos, con esta rutina me muestra los datos en el formulario, funciona muy bien


Private Sub UserForm_Initialize()
With ComCod
.ColumnHeads = True
.ColumnCount = 2
.ListWidth = 130
.ColumnWidths = "30;100"
.RowSource = Range("A6:B" & Range("A" & Rows.Count).End(xlUp).Row).Address
End With

ComEstEmp.AddItem "Activo"
ComEstEmp.AddItem "Inactivo"
ComEstEmp.AddItem "Despedido"
ComEstEmp.AddItem "Renuncio"
End Sub

Private Sub ComCod_change()
Dim rango As Range

Set rango = Range("A:A").Find(What:=ComCod, _
LookAt:=xlWhole, LookIn:=xlValues)

TextNomb = Range("B" & rango.Row)
TextCed = Range("C" & rango.Row)
TextFeNace = Range("D" & rango.Row)
ComEstCivil = Range("E" & rango.Row)
TextTelCe = Range("F" & rango.Row)
TextTelCa = Range("G" & rango.Row)
TextFeMod = Range("L" & rango.Row)
TextObs = Range("M" & rango.Row)

If Range("H" & rango.Row).Value = "SI" Then
OptSi.Value = True
Else: OptNo.Value = True
End If

TextSalB = Range("I" & rango.Row)
TextDir = Range("J" & rango.Row)
ComEstEmp = Range("K" & rango.Row)
End Sub[/CODE]

el problema biene ahora al presionar el boton deberia modificarse, pero solo me esta agregando fecha de modificacion y observaciones pero no me esta modificando el resto este es el codigo

[CODE]Private Sub BtnModEmp_Click()
'[A:A].Find(What:=ComCod, LookAt:=xlWhole).Activate

'Do While Not IsEmpty(ActiveCell)
' ActiveCell.Offset(1, 0).Select
'Loop
Set rango = Range("A:A").Find(What:=ComCod, _
LookAt:=xlWhole, LookIn:=xlValues)

Range("A" & rango.Row) = CDbl(TextCod)
Range("B" & rango.Row) = (TextNomb)
Range("C" & rango.Row) = CDbl(TextCed)
Range("D" & rango.Row) = CDate(TextFeNace)
Range("E" & rango.Row) = (ComEstCivil)
Range("F" & rango.Row) = CDbl(TextTelCe)
Range("G" & rango.Row) = CDbl(TextTelCa)

If OptSi.Value = True And OptNo.Value = False Then
Range("H" & rango.Row) = "Si"
Else: OptNo.Value = True And OptSi.Value = False
Range("H" & rango.Row) = "No"
End If

Range("I" & rango.Row) = CDbl(TextSalB)
Range("J" & rango.Row) = (TextDir)
Range("K" & rango.Row) = (ComEstCivil)
Range("L" & rango.Row) = CDate(TextFeMod)
Range("M" & rango.Row) = (TextObs)
End Sub[/CODE]

lo que esta con comilla son intentos mios para hacer funcionarlo pero sin resultado

alguna sugerencia?

he notado tambien que el combobox cambia el numero que muestra por un cero

probe con

[CODE]Cells(ComCod.ListIndex + 6, 1).Select[/CODE]

no me resulto tampoco

me doi cuenta que este codigo solo busca la primera fila vacia

[CODE]'[A:A].Find(What:=ComCod, LookAt:=xlWhole).Activate

'Do While Not IsEmpty(ActiveCell)
' ActiveCell.Offset(1, 0).Select
'Loop[/CODE]

planilla de empleados5.rar

Featured Replies

publicado
  • Autor

jajajajaja estuvo buenisimo el religioso muy buenisimo cheverisimo jajajajajaja

me explicarias que significan estas lineas

BtnModEmpClick = True

If Not ComCod.ListIndex = -1 Then

Fila = ComCod.ListIndex + 6[/CODE]

las he visto en varios archivos pero nunca de esta forma y nunca le agarre el truco

muchisimas gracias por la mano y vaya eres muy bueno para hacer codigos simples y ordenados

publicado

Te cuento, cada vez que modificas una celda que se usa con la propiedad RowSource en un combobox, se ejecuta el evento Change/Click del combobox.

Para evitar este efecto no deseado utilizamos la variable BtnModEmpClick que como veras la ponemos a True en el evento click del botón Ingresar, y en el evento Change del combobox preguntamos por esa variable para saltarnos todo el proceso del evento.

ComCod.ListIndex contiene el nº de elemento seleccionado en el combobox, sera igual a -1 cuando no se haya seleccionado ningún elemento o se haya escrito en él un valor inexistente.

Dado que los elementos dentro de un combobox se numeran a partir de cero, y nuestros datos empiezan a partir de la fila 6, de ahí que haya que sumar 6 al indice del combobox para obtener el nº de fila de los datos a actualizar.

publicado
  • Autor

ahhhh entiendo mmmm una muy buena explicacion!!!

muchisimas gracias por tu ayuda y aclaracion

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.