how to get msgbox when cell value varies exel vba

Viewed 111

I have a cell "A1" which varies the integer values from "1 to 150" suppose if "A1"cell.Value ="1" then i should get msgbox containing its A1 value as "1". and if"A1"cell value = "2" then i should get msgbox containing its A1 value as "2"

similarly if A1 value is 3,4,5 and so on, then i should get respective cell value in msgbox I wrote a code as seen below. but writing if code statement ranging from "1 to 150" is dificult task can anybody minimise thise code adding variables to this.. thank you in advance

sub variable()    
    If Range("a1").Value = 1 Then
        MsgBox Worksheets("Sheet1").Range("A1").Value
    Else
        If Range("a1").Value = 2 Then
           MsgBox Worksheets("Sheet1").Range("A1").Value
        Else
           If Range("a1").Value = 3 Then
               MsgBox Worksheets("Sheet1").Range("A1").Value 
           End If
        End If
    End If    
End Sub
3 Answers
Related