So my code is setting up to send an email with all the lines that meet a certain cell name (Missing Text). if there are none of those in the search i want it to bypass and enter in a "None". If there are cells that have it, it works great, but if there is none i get a Subscript out o range error.
Dim MissingText() As Variant
Dim WrongNum() As Variant
Dim BlankText() As Variant
Dim objOutlook As Object
Dim objMsg As Object
Set objOutlook = CreateObject("Outlook.Application")
Erase MissingText, WrongNum, BlankText
Listed = 0
Ending = Cells(Rows.Count, 5).End(xlUp).Row
n = 0
For Listed = 2 To Ending
If Cells(Listed, 10).Value = "Missing Text" Then
ReDim Preserve MissingText(n)
MissingText(n) = Listed
n = n + 1
End If
Next Listed
If IsEmpty(MissingText) Then
MissingTogether = "None"
GoTo MissingSkip
End If
CountArray = UBound(MissingText, 1) - LBound(MissingText, 1) + 1
CountArray = CountArray - 1
MissingTogether = Join(MissingText, ", ")
MissingSkip:
(continues on ) At the CountArray = UBound(MissingText, 1) - LBound(MissingText, 1) + 1 is when the error occurs. any help would be nice, thank you.