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.

Seleccionar datos de ListBox Multiselección desde macro al cargar

publicado

Buenas

Tengo una excel a la que le inserto datos a través de un formulario, y los datos pueden modificarse a través de otro formulario. El problema es que uno de los campos es un listBox multiselección que al insertarlos datos los coloca en una celda separados por ",". Pero al recuperar los datos no consigo que el listbox queden esos datos seleccionados al cargarse.

¿Podeis ayudarme?

Sub modificardat()    
On Error GoTo ErrorHandler
'recuperamos el indice de control de la solicitud
indice = SelecionarDatoForm.ListBox1.Value

Unload SelecionarDatoForm

'borramos los datos de la hoja 3
Worksheets("Hoja2").Range("A1:P" & Ult).Delete


'buscamos el indice en la hoja pet. cat. la fila en la que se encuentra el registro a modificar
Worksheets("pet. cat.").Activate
Range("P4:P" & totalreg).Find(indice, SearchOrder:=xlByRows).Activate
b = ActiveCell.Row
' cargamos el formulario de modificación con los datos actuales del registro
Load ModificarDatoForm
With ModificarDatoForm
.TextBoxNumPeticion.Value = Worksheets("pet. cat.").Range("A" & .Value
fecha1 = Replace(Worksheets("pet. cat.").Range("B" & .Value, "'", "")
.TextBoxFecha1.Value = fecha1
.TextBoxAsunto.Value = Worksheets("pet. cat.").Range("C" & .Value
.TextBoxSolicitado.Value = Worksheets("pet. cat.").Range("D" & .Value
.ListBoxSituación.Value = Worksheets("pet. cat.").Range("E" & .Value
If .ListBoxSituación.Value = "Finalizado" Then
.FechaLabel2.Visible = "True"
.TextBoxFecha2.Visible = "True"
fecha2 = Replace(Worksheets("pet. cat.").Range("F" & .Value, "'", "")
.TextBoxFecha2.Value = fecha2
Else
.FechaLabel2.Visible = "False"
.TextBoxFecha2.Visible = "False"
End If
'recuperamos los datos de la entidad
[COLOR=#ff0000] Call Distribuye[/COLOR]

[COLOR=#ff0000] Worksheets("Hoja1").Activate[/COLOR]
[COLOR=#ff0000] Range("A30").Select[/COLOR]
[COLOR=#ff0000] Selection.End(xlUp).Select[/COLOR]
[COLOR=#ff0000] fin = ActiveCell.Row[/COLOR]

[COLOR=#ff0000] For i = 0 To .ListBoxEntidad.ListCount - 1[/COLOR]
[COLOR=#ff0000] For j = 15 To fin[/COLOR]
[COLOR=#ff0000] If .ListBoxEntidad.List(i) = Worksheets("Hoja1").Range("A" & j).Value Then[/COLOR]
[COLOR=#ff0000] .ListBoxEntidad.Selected(i) = True[/COLOR]
[COLOR=#ff0000] End If[/COLOR]
[COLOR=#ff0000] Next j[/COLOR]
[COLOR=#ff0000] Next i[/COLOR]
[COLOR=#ff0000] Worksheets("Hoja1").Range("A15:A" & fin).Delete[/COLOR]

.TextBoxAcciones.Value = Worksheets("pet. cat.").Range("J" & .Value
.TextBoxObservaciones.Value = Worksheets("pet. cat.").Range("K" & .Value

.Show
End With


On Error GoTo 0
ErrorHandler:
If Err.Number <> 0 Then
MsgBox Err & ": " & Error(Err)
End If

End Sub
Sub Distribuye()
Matriz = Split(Worksheets("pet. cat.").Range("G" & .Value, ",")
On Error Resume Next
For i = 0 To 10
If IsNull(Matriz(i)) = False Then
Worksheets("Hoja1").Range("A" & i + 15).Value = Matriz(i)
If Err.Number = 9 Then
i = 20
End If
End If
Next




End Sub


[/CODE]

Copia de Seguimiento PeticionesPrueba.rar

Featured Replies

No hay posts para mostrar

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.