Kamis, 02 April 2015

[ExcelVBA] Simple loop help


Hi All,

Having difficulty running this loop. I am try to determine the integer value of a cell to return its card rank. i.e. 2=2





Here is the code, but I get multiple errors.

Private Sub RankCheck()

Dim i As Integer, CurrentCell As Long

For i = 1 To 52
    CurrentCell = Cells(i, 1)
        If Int(CurrentCell) = 11 Then
            Cells(i, 2).Value = "Jack"
        ElseIf Int(CurrentCell) = 12 Then
            Cells(i, 2).Value = "Queen"
        ElseIf Int(CurrentCell) = 13 Then
            Cells(i, 2).Value = "King"
        ElseIf Int(CurrentCell) = 14 Then
            Cells(i, 2).Value = "Ace"
        Else: Cells(i, 2).Value = Int(CurrentCell)
        End If
Next i

End Sub

Any help is appreciated. 


Posted by: jeff.flanagan@duffcorp.ca
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

Visit our ExcelVBA group home page for more info and support files:

More free tutorials and resources available at:




Tidak ada komentar:

Posting Komentar