Jump to content
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.

Variables en Macro + abecedario que de A pase a B, C, D

Posted

 

Buena Tarde 

 

Tengo una macro en la que tengo algunas variables, una de ellas string pero es para recorrer las celdas, la inicializo con E, la siguiente debe ser F, G, H, I asi consecutivo para que realice una suma 

al avanzar en la macro de cada una de las celdas, corriendo el filtro, pero esta variable no he podido, hacer que pueda decirle next y sea la siguiente letra del alafabeto, como podria hacer esto ? 

 

Gracias 

 

Esta es la macro  

 

Dim n&, cCriterio$, H&, LE As String

    j = 5
    LE = "E"
    
    For H = 5 To 10

    For n = j To 19
        If n = j Then cCriterio = "<>0" Else cCriterio = "0"
        ActiveSheet.Range("$A$11:$AH$" & fila).AutoFilter Field:=n, Criteria1:=cCriterio
    Next n

'suma
        Range(LE & 10).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(LE & 11).Select
    Selection.End(xlDown).Select
    Range(LE & fila).Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[-482]C:R[-2]C)"
    Range(LE & fila).Select
    Selection.Copy
    Selection.End(xlUp).Select
    Range(LE & 9).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        


    Rows("11:11").Select
    ActiveSheet.ShowAllData
    Range("A10").Select
    
   LE = "F"
    
    j = j + 1
    n = j
          
          Next H

 

Gracias 

 

 

Featured Replies

  • Author

Gracias Edgar 

 

Adjunto el archivo donde se puede ver el detalle de la macro, lo que requiero es poder hacer que la variable LE que empieza en E, su siguiente valor sea F, luego G y asi consecutivamente hasta la Y

 

Gracias

Variable.xlsm

  • Author

Leopoldo Gracias, pero me sirve porque en la formula de la suma que es donde la uso, no puedo  poner lo asi ya que se va a la columna N:

Range( n & 10).Select 

 

Range(LE & 10).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(LE & 11).Select
    Selection.End(xlDown).Select
    Range(LE & fila).Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[-482]C:R[-2]C)"
    Range(LE & fila).Select
    Selection.Copy
    Selection.End(xlUp).Select
    Range(LE & 9).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

 

  • Author

 

Leopoldo, ya valide y no funciona, ademas el cells no me permite sacar la suma del rango de la columna.

 

la suma es porque se requiere filtrar la columna con valores inicial, osea la E y las demas filas filtrarlas con 'cero' y sacar la suma de esos filtros e irlos dejando en la fila 9, en el siguiente ciclo toma es los valores de la siguiente columna la F y los demas en 'ceros' asi consecutivamente.

 

Gracias  

Hola segalo,

Te voy a creer, por que no lo he realizado como lo tienes... pero...

Te hice este FORCITO... y esta seria una manera, otra seria con For Each...o...

 

Sub SigCol_LBV()
Dim aCol, n&, LE$
    aCol = Array("E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y")
    For n = LBound(aCol) To UBound(aCol)
        LE = aCol(n)
        MsgBox LE
    Next n
End Sub

Saludos

 

Edited by Leopoldo Blancas

Con independencia de que la macro se puede enfocar de otra forma, simplemente:

For Each celda In Range("E10:Y10")
   celda.select 'Fila 10
...
   celda.Offset(1).Select  'Fila 11
...
   celda.Offset(-1).select 'Fila 9
...
Next

 

Archived

This topic is now archived and is closed to further replies.

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.