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 calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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