expand data selection range

dragonfire33

Board Regular
Joined
Oct 7, 2021
Messages
90
Office Version
  1. 365
Platform
  1. Windows
What line should I add to extend the range to "g16: m25" please any help would be very useful
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim uF&, i&, nBusca%, Celda As Range
    If Not Intersect(Target, Columns(4)) Is Nothing Then
        Range("G3:G12,I3:I12,K3:K12,M3:M12").Interior.Color = vbWhite
        For i = 0 To 3
            nBusca = Target.Offset(0, i - 3)
            Select Case i
                Case 0
                    Set Celda = Range("G3:G12").Find(nBusca, , , xlWhole)
                Case 1
                    Set Celda = Range("I3:I12").Find(nBusca, , , xlWhole)
                Case 2
                    Set Celda = Range("K3:K12").Find(nBusca, , , xlWhole)
                Case 3
                    Set Celda = Range("M3:M12").Find(nBusca, , , xlWhole)
            
               
            End Select
            If Not Celda Is Nothing Then
                Celda.Interior.Color = vbRed
            End If
        Next i
        Range("G2").Activate
    End If
End Sub
 

Attachments

  • 22.png
    22.png
    128.9 KB · Views: 15

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
To make the change your wanting change your code to this:
VBA Code:
Range("G16:M25").Interior.Color = vbWhite

But then in your previous post you were searching every other column.
If that's what you really want to do you would have to modify other parts of your code also
 
Upvote 0
Para realizar el cambio que desea, cambie el código a este:
VBA Code:
 Rango ("G16:M25"). Interior.Color = vbWhite

Pero luego, en tu publicación anterior, estabas buscando en todas las demás columnas.
Si eso es lo que realmente quieres hacer, también tendrías que modificar otras partes de tu código.
la idea es resaltar el número entre las columnas abcd de las dos tablas
 
Upvote 0
Para realizar el cambio que desea, cambie el código a este:
VBA Code:
 Rango ("G16:M25"). Interior.Color = vbWhite

Pero luego, en tu publicación anterior, estabas buscando en todas las demás columnas.
Si eso es lo que realmente quieres hacer, también tendrías que modificar otras partes de tu código.
¿cómo puedo modificarlo para que destaque en las otras columnas?
 
Upvote 0
If you wish to post your question in your native language, please note that there is a "Questions in Other Languages" forum found here:
 
Upvote 0
the idea is to color the cells in the tables according to the abcd columns
 

Attachments

  • 22.png
    22.png
    128.9 KB · Views: 10
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,164
Members
453,021
Latest member
Justyna P

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