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

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Your orginal script skipped every other column
As the new range does not.
 
Upvote 0

Forum statistics

Threads
1,215,256
Messages
6,123,912
Members
449,132
Latest member
Rosie14

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