Patients Table in Excel
A
1 |Patient Name |
2 |Jane Doe |
When this table has just one patient listed, the following routine fails:
Sub RunMerge()
Dim ptsArray As Variant
Dim strPtName As Variant
Dim lRowCount As Long
lRowCount = Worksheets("Patients").UsedRange.Rows.Count
ptsArray = ThisWorkbook.Worksheets("Patients").Range("A2:A" & lRowCount).value
For Each strPtName In ptsArray
. . .
Next
End Sub
Within the VBA editor I see strPtName is showing empty but ptsArray shows that it contains Jane Doe. And the program stalls. But if I add a second patient or more all works as it should. What am I missing in order to run the routine in the event that only one patient is left.