expand data selection range

dragonfire33

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

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
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: 7
Upvote 0

Forum statistics

Threads
1,215,223
Messages
6,123,715
Members
449,118
Latest member
MichealRed

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