modificar el rango al codigo

dragonfire33

Board Regular
Joined
Oct 7, 2021
Messages
90
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: 25

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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,224,862
Messages
6,181,458
Members
453,042
Latest member
AbdelrahmanExcel

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