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.

Asiganar validacion de datos rango variable

publicado

Intento hacer una lista desplegable en un rango de celdas, los datos son el resultado de una extracción en otra hoja. Excel 2007. Este código esta en el modulo de la hoja1:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim mLista, nLista

If Intersect(Target, [b5:b21,c25:c26]) Is Nothing Then Exit Sub
[b5:b21,c5:c26].Validation.Delete
Application.ScreenUpdating = False

With Hoja2
.[a1].CurrentRegion.AdvancedFilter 2, .[c1:c2], .[f1], False

If .[f3] <> "" Then
mLista = WorksheetFunction.Transpose(.Range(.[f2], .[f1].End(xlDown)).Value)
[b5:b21].Validation.Add 3, 1, 1, Join(mLista, ",")
ElseIf .[f2] <> "" Then
[b5:b21].Validation.Add 3, 1, 1, .[f2]
End If
.[f1].CurrentRegion.Delete
ActiveCell.Offset(, 1).Activate: ActiveCell.Offset(, -1).Activate
nLista = .Range(.[a2], .[a2].End(xlDown))
[c5:c26].Validation.Add 3, 1, 1, Join(nLista, ",")
End With

Application.ScreenUpdating = True
End Sub[/CODE]

Las listas las intento poner en el rango c5:c26 y el rango variable proviene de la hoja2 desde la celda A2

¿Como puedo validar datos en el rango c5:c26 de la hoja1 desde el rango a2 hasta la ultima celda no vacía de la hoja2?

Me da fallo en esta linea:

[CODE][c5:c26].Validation.Add 3, 1, 1, Join(nLista, ",")[/CODE]

argumento no valido.

Gracias.

Libro.rar

Featured Replies

publicado

@[uSER=121392]highlander38[/uSER] realmente no entiendo que haces alli, pero bueno, creo que si cambias esto

nLista = .Range(.[a2], .[a2].End(xlDown))[/CODE]

por esto otro te deberia funcionar

[CODE] nLista = WorksheetFunction.Transpose(.Range(.[a2], .[a2].End(xlDown)).Value)[/CODE]

suerte

publicado
  • Autor

Funciona perfecto bigpetroman.

En el rango de celdas coloreada, cuando seleccionas algo de la lista desplegable, desaparece ese valor, para evitar duplicados.

En el otro rango intentaba conseguir la lista tal cual.

Queria agregar un rango variable, y segun veo en la ayuda de vba, transpose lo hace como un objeto variable.

Muchisimas gracias por la solucion.

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.