pjs
pjs

Reputation: 13

VBA print a value in msg box

I'm stuck in an assignment for school, this is what i have to do:

This is the current code I have:

Upvotes: 0

Views: 204

Answers (2)

Marco
Marco

Reputation: 1349

It is better if you loop through all cells individually, like this:

Dim i As Integer

'9 means column I and 13 is column M
For i = 9 To 13
    ' Getting the percent values
    Debug.Print Worksheets("Summary").Cells(80, i).Value
Next

This way you can continue by yourself.

Upvotes: 0

R3uK
R3uK

Reputation: 14547

You need to loop in the array you've loaded and :

Sub Ratio()

Dim OperatingRatio() As Double
Dim j As Long

With Sheets("Summary")
    OperatingRatio = .Cells("I80:M80").Value

    For j = LBound(OperatingRatio, 2) To UBound(OperatingRatio, 2)
        If OperatingRatio(1, j) > 100 Then
            MsgBox .Cells(14, 9 + j)
            .Cells(80, 9 + j).Interior.Color = vbRed
        Else
        End If
    Next j
End With

End Sub

Upvotes: 3

Related Questions