Hi all,

I'm having some issues with ending a loop function when no data is populated. Currently the cell I'm targeting has a formula within it that is blank ("") unless data is populated. The below script is what I have put together, but it continues to run all the way to the end, thus providing empty rows of data in the report. I would ideally like it to stop and move on to the next part of the script when blank cells are seen. Any advice would be much appreciated.

Thank you

Dim Txt As String
Dim RepDate As Date
Dim wks As Worksheet
Dim CRow As Integer

Set wks = Worksheets("Mailer")

RepDate = Date

Txt = Txt & wks.Cells(12, 3) & vbCrLf
Txt = Txt & wks.Cells(13, 3) & vbCrLf
Txt = Txt & wks.Cells(13, 4) & vbCrLf
Txt = Txt & wks.Cells(13, 5) & vbCrLf
Txt = Txt & wks.Cells(13, 6) & vbCrLf
Txt = Txt & wks.Cells(13, 7) & vbCrLf
Txt = Txt & wks.Cells(13, 8) & vbCrLf & vbCrLf

CRow = 14

Do While CRow < 20
'If wks.Cells(5, 2) <> 0 Then
'Txt = Txt & "GLC Report" & vbCrLf



Txt = Txt & wks.Cells(12, 3)
Txt = Txt & wks.Cells(CRow, 2) & vbCrLf
Txt = Txt & wks.Cells(CRow, 3) & vbCrLf
Txt = Txt & wks.Cells(CRow, 4) & vbCrLf
Txt = Txt & wks.Cells(CRow, 5) & vbCrLf
Txt = Txt & wks.Cells(CRow, 6) & vbCrLf
Txt = Txt & wks.Cells(CRow, 7) & vbCrLf
Txt = Txt & wks.Cells(CRow, 8) & vbCrLf & vbCrLf
Txt = Txt
'End If

CRow = CRow + 1
Loop


Gather_Open_Data = Txt
Set wks = Nothing

End Function