Loop through ranges inside condition

AlaaEddin

New Member
Joined
May 2, 2018
Messages
25
Hello There,

I have the following code:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)    

    If Target.Address = "$B$12" Then
        Range("C12").Value = "Please Select..."
    End If
    If Target.Address = "$C$12" Then
        Range("D12").Value = "Please Select..."
    End If
    
    If Target.Address = "$B$13" Then
        Range("C13").Value = "Please Select..."
    End If
    If Target.Address = "$C$13" Then
        Range("D13").Value = "Please Select..."
    End If

    If Target.Address = "$B$14" Then
        Range("C14").Value = "Please Select..."
    End If
    If Target.Address = "$C$14" Then
        Range("D14").Value = "Please Select..."
    End If

End Sub

so what I need is too loop this so I don't need to define each row individually
Thanks in advance.
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Perhaps something like this, with the row limits set as needed.
Code:
With Target
    If .Cells.Count = 1 Then
        If .Column = 2 Or .Column = 3 Then
            If 12 <= .Row And .Row <= 14 Then
                Application.EnableEvents = False
                .Offset(0,1).Value = "Please Select..."
                Application.EnableEvents = True
            End If
        End If
    End IF
End With
 
Upvote 0
The code does work but there's a problem that when the value of D12 isn't changed when the value of B12 changed so I need this to be performed also the count of columns and rows is going to be more than this so I need you to clarify how I can customize this formula to match my needs.

Thanks you so much your help is really appreciated
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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