none
return cell values in a msgbox RRS feed

  • Question

  • Hi

    I got below code where I would like to add cells that makes the message_box appear (different values) into the msg box.

     

    Sub Check_Data_values()

    With Worksheets("data")

    MyCount = Application.CountA(Range("A:A"))

        For X = 2 To MyCount
        y = X + 1
        'Value1 = Cells(X, 1).Value
        'Value2 = Cells(y, 1).Value
           
            If Cells(X, 1).Value <> Cells(y, 1).Value Then MsgBox ("check cells") ' here I would like cells that are compared
           
           
        Next X

       
    End With
    End Sub


    Sverreberre

    Thursday, October 3, 2013 2:59 PM

All replies

  • Hi

    I got below code where I would like to add cells that makes the message_box appear (different values) into the msg box.

    Sub Check_Data_values()

    With Worksheets("data")

    MyCount = Application.CountA(Range("A:A"))

        For X = 2 To MyCount
        y = X + 1
        'Value1 = Cells(X, 1).Value
        'Value2 = Cells(y, 1).Value
           
            If Cells(X, 1).Value <> Cells(y, 1).Value Then MsgBox ("check cells") ' here I would like cells that are compared
           
           
        Next X

       
    End With
    End Sub


    Sverreberre

    I don't really understand your question. Do you just want to display the cell value in the message box. Just use

    MsgBox(Cells(X, 1).Value)

    Thursday, October 3, 2013 3:45 PM