Home » excel » excel – Calling individual cell instead of range

excel – Calling individual cell instead of range

Posted by: admin May 14, 2020 Leave a comment

Questions:

The below macro is pulling a value from a cell which is referencing a range and then actioning accordingly. How can I change this to only run the case for the relevant entry in the cell?

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If Target.Address = "$C$5" Then
        Select Case Target.Value
        Case Phones4U, P4U
        Case MBNA, MBNA1
        'Case Is = O2, The_Problem_Network
        'Case Is = TMobile, TMobile
        'Case Is = 3, Run_3
        'Case Is = Orange, Orange
        'Case Is = Carphone_Warehouse, CPW
        'Case Is = Virgin_Media, VirginMedia
        'Case Is = Virgin_Mobile, VirginMobile
        'Case Is = Lifestyle_Group, LSG
        'Case Is = BT, BT
        'Case Is = Barclays, Barclays
        'Case Is = Nat_West, NatWest
        'Case Is = RBS, RBS
        'Case Is = Unipart, Unipart
        'Case Is = Vodafone_Group, Vodafone
    End Select
    End If
End Sub

Thanks for your help.

How to&Answers:

I think that a syntax like this should work without problems

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$C$5" Then
        Select Case Target.Value
        Case "Phones4U"
                P4U
        Case "MBNA"
                MBNA1
        Case "O2"
                The_Problem_Network
       ' etc
    End Select
    End If

End Sub