+ Reply to Thread
Results 1 to 2 of 2

using statement "case" using vba program

Hybrid View

  1. #1
    Registered User
    Join Date
    04-03-2009
    Location
    indonesian
    MS-Off Ver
    Excel 2003
    Posts
    3

    using statement "case" using vba program

    problem with myself, i can't make sourcedove in vba program to use statement "case"

    with condition if the value in a cell (exAmple) in cell A1 => result in cell B1

    "812, 813, 814, 815" (Cell A1) value is "AUSTRALIA"(as result at cell B1)
    and if "511, 611, 711, 852, 845, 911" (cell A1) value is "BANGKOK" (as result at cell B1)
    and other is "roamer"

    pls help me..
    10Q verimuch

    the beginner

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: using statement "case" using vba program

    Hi Novri, and welcome to the forum.

    The Select Case statement shown below should be what you're looking for:
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Target, Range("A1")) Is Nothing Then
            Select Case Range("A1").Value
                Case 812 To 815
                    Range("B1").Value = "Australia"
                Case 511, 611, 711, 845, 852, 911
                    Range("B1").Value = "Bangkok"
                Case Else
                    Range("B1").Value = "Roamer"
            End Select
        End If
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1