modificar el rango al codigo

dragonfire33

Board Regular
Joined
Oct 7, 2021
Messages
52
Office Version
  1. 365
Platform
  1. Windows
como puedo modificar el rango a este codigo , que no solamente se ejecute con el numero de la columna A , sino que se ejecute con el numero dividido entre la columna A a la columna D y se marque en los cuadros del lado derecho y se vaya señalado con el cuadro de color rojo de la columna E para saber en que numero va
VBA Code:
Private Sub SpinButton1_Change()
  Dim n%, valor As String ' <= variable agregada '
  Application.ScreenUpdating = False
  If [A1] = "0000" Then Exit Sub
  valor = Format([A1], "0000") ' <= formato agregado '
  For i = 1 To Sheets.Count
    Sheets(i).Activate
    [A1] = valor
    For n = 1 To Len(valor)
      BuscarÁrea n, Mid(valor, n, 1), 4, 13
      BuscarÁrea n, Mid(valor, n, 1), 17, 26
    Next
  Next
End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address Like "$A$*" Then
   If Not ActiveCell = "" Then
      If IsNumeric(ActiveCell) Then SpinButton1 = ActiveCell
   End If
End If
End Sub
 

Attachments

  • 11.png
    11.png
    138 KB · Views: 20

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
como puedo modificar el rango a este codigo , que no solamente se ejecute con el numero de la columna A , sino que se ejecute con el numero dividido entre la columna A a la columna D y se marque en los cuadros del lado derecho y se vaya señalado con el cuadro de color rojo de la columna E para saber en que numero va
VBA Code:
Private Sub SpinButton1_Change()
  Dim n%, valor As String ' <= variable agregada '
  Application.ScreenUpdating = False
  If [A1] = "0000" Then Exit Sub
  valor = Format([A1], "0000") ' <= formato agregado '
  For i = 1 To Sheets.Count
    Sheets(i).Activate
    [A1] = valor
    For n = 1 To Len(valor)
      BuscarÁrea n, Mid(valor, n, 1), 4, 13
      BuscarÁrea n, Mid(valor, n, 1), 17, 26
    Next
  Next
End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address Like "$A$*" Then
   If Not ActiveCell = "" Then
      If IsNumeric(ActiveCell) Then SpinButton1 = ActiveCell
   End If
End If
End Sub
 
Sub BuscarÁrea(n As Integer, Número As Integer, x1 As Long, x2 As Long)
Application.ScreenUpdating = False

y = (n - 1) * 2 + 5  'empieza en col E
aTablas:
Range(Cells(x1, y), Cells(x2, y)).Interior.ColorIndex = xlNone
For x = x1 To x2
   If Cells(x, y) = Número Then
      Cells(x, y).Interior.Color = vbRed
      'pasa a la tbla siguiente
      GoTo siguenTablas
   End If
Next

siguenTablas:
'sigue con otras tablas
y = y + 9
If y > 57 Then Exit Sub
GoTo aTablas
End Sub
 
Upvote 0
como puedo modificar el rango a este codigo , que no solamente se ejecute con el numero de la columna A , sino que se ejecute con el numero dividido entre la columna A a la columna D y se marque en los cuadros del lado derecho y se vaya señalado con el cuadro de color rojo de la columna E para saber en que numero va
VBA Code:
Private Sub SpinButton1_Change()
Dim n%, valor As String ' <= variable agregada '
Application.ScreenUpdating = False
If [A1] = "0000" Then Exit Sub
valor = Format([A1], "0000") ' <= formato agregado '
For i = 1 To Sheets.Count
Sheets(i).Activate
[A1] = valor
For n = 1 To Len(valor)
BuscarÁrea n, Mid(valor, n, 1), 4, 13
BuscarÁrea n, Mid(valor, n, 1), 17, 26
Next
Next
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address Like "$A$*" Then
If Not ActiveCell = "" Then
If IsNumeric(ActiveCell) Then SpinButton1 = ActiveCell
End If
End If
End Sub
Sub BuscarÁrea(n As Integer, Número As Integer, x1 As Long, x2 As Long)
Application.ScreenUpdating = False
y = (n - 1) * 2 + 5 'empieza en col E
aTablas:
Range(Cells(x1, y), Cells(x2, y)).Interior.ColorIndex = xlNone
For x = x1 To x2
If Cells(x, y) = Número Then
Cells(x, y).Interior.Color = vbRed
'pasa a la tbla siguiente
GoTo siguenTablas
End If
Next
siguenTablas:
'sigue con otras tablas
y = y + 9
If y > 57 Then Exit Sub
GoTo aTablas
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,322
Messages
6,124,241
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top