1 year ago

#77435

test-img

WhiteTiger4

Trying to build a case structure

I am trying to build a case structure using If/ElseIf statements, but I'm not sure what to dimension my "Region" variable to use a decision variable to be used later on. (Say later I want to add more code based on what the Region the variable falls into) Can anyone help?

Dim Region 

Dim RegionString As String

RegionString = TransmittalSubmittalActiveWorksheet.Range("A1").Value

    If RegionString Like "*NORTH*" Then ' "North" is case sensitive
        Debug.Print RegionString
        Region = NORTH
        Debug.Print Region
    ElseIf RegionString Like "*WEST*" Then
        Debug.Print RegionString
        Region = WEST
    ElseIf RegionString Like "*CHICAGO*" Then
        Debug.Print RegionString
        Region = CHICAGO
    ElseIf RegionString Like "*SOUTH*" Then
        Debug.Print RegionString
        Region = SOUTH
    ElseIf RegionString Like "*NUCLEAR*" Then
        Debug.Print RegionString
        Region = NUCLEAR
    End If

excel

vba

0 Answers

Your Answer

Accepted video resources