|
-
Apr 22nd, 2013, 08:06 AM
#1
Thread Starter
New Member
End Loop on Empty Cell
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
-
Apr 22nd, 2013, 08:24 AM
#2
-
Apr 22nd, 2013, 09:20 AM
#3
Re: End Loop on Empty Cell
Moved to the Office Development forum.
-
Apr 22nd, 2013, 09:40 AM
#4
Thread Starter
New Member
Re: End Loop on Empty Cell
Thank you for your replies, I'll move to the Office Development forum.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|