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.
Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
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.