message box

Frankie needs HELP

New Member
Joined
Apr 3, 2002
Messages
43
Date admitted
16/09/2001
21/11/2001
10/09/2001
06/06/2001

05/01/2001

22/03/2001
Above is one of the columns out of my spreadsheet data. There are gaps in the data. I need to produce a macro that gives me a warning when there is a gap to make aware that a patient hasn't been admitted. Does anyone know how I could do this?
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Sure can Frankie.

I put your data starting in cell A1 on sheet1. Then I put this code together:

<pre>
Public Sub Frankie()

If Sheets("Sheet1").Range("A1").End(xlDown) <> Sheets("Sheet1").Range("A65536").End(xlUp) Then
MsgBox "Oi, there are patients still to be admitted", vbInformation, "Patients"
End If

End Sub</pre>

This basically looks for the first blank space and the last used cell, if they are not the same cell then the message will show.

HTH
 
Upvote 0
Here's another way if you wish to know the count of blanks as well.

Code:
Sub GapsOrNot()
Dim iCount As Integer

iCount = WorksheetFunction.CountBlank(Sheet1.Range("A1", Sheet1.Range("A65536").End(xlUp)))
If iCount <> 0 Then
 MsgBox "You have " & iCount & " gaps"
End If

End Sub
 
Upvote 0
Thanks for the help guys (Mark O'Brian, Dave Hawley) but when I step into the macro a Compile error comes up saying:

Wrong numbers of arguments or invalid property assignment

Why is this??
 
Upvote 0
Dave your code worked for me, but Mark, you code runs, but it doesn't seem to return the correct result.
 
Upvote 0
Ok I've got Daves working, but how would I change the macro a little so that a warning mesage would appear if no one on the list had been admitted.
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,998
Members
448,541
Latest member
iparraguirre89

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top