Message to appear when 5 cells uncolored cells contain values.

Solved/Closed
Fmss8404 Posts 1 Registration date Monday 12 August 2019 Status Member Last seen 12 August 2019 - 12 Aug 2019 à 21:52
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 13 Aug 2019 à 11:50
Hello,
A macro using excel that can return a message when 5 uncolored cells that are in a range of colored and uncolored cells contain values. The message to display “5”.
Related:

1 response

TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 555
13 Aug 2019 à 11:50
Hi Fmss8404,

To do that specific task, give the following code a try:
Sub RunMe()
Dim x, y As Integer, mRange As Range

Set mRange = Application.InputBox("Select range", Type:=8)

For Each cell In mRange
    If cell.Interior.Pattern = xlNone Then x = x + 1
    If cell.Value <> vbNullString Then y = y + 1
Next cell

If x = 5 And y = 5 Then MsgBox ("5")
End Sub


Best regards,
Trowa