Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to put cell that for loop is in, in a message box

I’m using Vba and want to be able to put the cell the for loop is in into a msgbox.
This is my code:

For Each Cell In Range("C5:C11")
    If Cell.Value = 0 Then
         MsgBox "Please input a number for cell " & Cell & " that isn't 0."
    End If 

I’m not sure exactly what to put to get the code to output the cell the for loop is currently on in the msgbox.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

you may be after this:

For Each Cell In Range("C5:C11")
    If Cell.Value = 0 Then
        MsgBox "Please input a number for cell " & Cell.Address & " that isn't 0."
    End If
Next
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading