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.

Macro para hojas Libro ??

publicado

Hola buenas.

Tengo esta macro que quisiera que se ejecute en hojas determinadas del libro

Private Sub CommandButton1_Click()

Dim NX As Integer, N2 As Integer
Dim CX As Integer, C2 As Integer, SEL As Integer

If Not IsNumeric(TextBox1) Then
   MsgBox "Cantidad X incorrecta"
   Exit Sub
End If
If Not IsNumeric(TextBox2) Then
   MsgBox "Cantidad 2 incorrecta"
   Exit Sub
End If
If CheckBox1 Then Combinar
Application.ScreenUpdating = False
NX = CInt(TextBox1)
N2 = CInt(TextBox2)
For y = [B18] + 3 To 4 Step -1
   CX = 0: C2 = 0: SEL = 0
   For x = 0 To 13
      If ListBox1.Selected(x) Then
         SEL = SEL + 1
         If Cells(x + 1, y) = "X" Then CX = CX + 1
         If Cells(x + 1, y) = "2" Then C2 = C2 + 1
      End If
   Next
   If SEL > 0 Then
      If Not (CX = NX And C2 = N2) Then
         Cells(1, y).Resize(14, 1).Delete shift:=xlToLeft
         [B18] = [B18] - 1
      End If
   End If
Next
Application.ScreenUpdating = True
End Sub

 

Un Saludo.

Editado el por eugeniocol
restificar

Featured Replies

publicado

eugeniocol

 

Vayamos por partes:

Supuesto: Todas las Hojas, donde se va a ejecutar la macro, deben estar estructuradas de la misma manera.

Parece que se ejecuta desde un Formulario ya que veo que hay Textbos, Listbox, etcc...

Pero tambien veo un bucle que ataca las celdas directamente (Cells(x + 1....)

Entonces lo unico que necesita la macro es saber con que hoja está trabajando. Pues pasemos le una variable con la hoja donde se va a ejecutar.

Crearia un Procedimiento Sub en un modulo independiente. Y copiaria todo lo que has puestoy cambiaria lo que te pongo

Sub TuNombreDeProcedimiento (TuHoja as Sheets)

'Todo

.........

With TuHoja

.Cells(x+1, ....

end with

Y lo Llamas desde el procedimeitno privado 'Al Hacer Click'

Private Sub CommandButton1_Click()

call TuNombreDeProcedimiento (ElNombreDeLaHojaApasar)

End Sub

Espero Te sirva en tu desarrollo

Saludos

 

Editado el por ikanni

publicado
  • Autor
Hace 8 horas, ikanni dijo:

eugeniocol

 

Vayamos por partes:

Supuesto: Todas las Hojas, donde se va a ejecutar la macro, deben estar estructuradas de la misma manera.

Parece que se ejecuta desde un Formulario ya que veo que hay Textbos, Listbox, etcc...

Pero tambien veo un bucle que ataca las celdas directamente (Cells(x + 1....)

Entonces lo unico que necesita la macro es saber con que hoja está trabajando. Pues pasemos le una variable con la hoja donde se va a ejecutar.

Crearia un Procedimiento Sub en un modulo independiente. Y copiaria todo lo que has puestoy cambiaria lo que te pongo

Sub TuNombreDeProcedimiento (TuHoja as Sheets)

'Todo

.........

With TuHoja

.Cells(x+1, ....

end with

Y lo Llamas desde el procedimeitno privado 'Al Hacer Click'

Private Sub CommandButton1_Click()

call TuNombreDeProcedimiento (ElNombreDeLaHojaApasar)

End Sub

Espero Te sirva en tu desarrollo

Saludos

 

Voy a ver que saco de esto

Salud2....

 

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.