First of all, thank you in advance for helping me out with my dilemma,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o> </o>
I have the following code that exports certain cell values, along with message from excel to outlook. It works great, provided that there are values in all those cells mentioned in the code. How do I re-write it to work even when some of the cells are blank?<o></o>
<o> </o>
Public Sub Test777()
Dim olApp As Object, olMail As Object
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(0)
olMail.To = "someone@yahoo.com"
olMail.Subject = "Mfg Shift Report"
olMail.body = "Line " & Range("A4") & " - " & Range("B4") & " - " & Range("C4") & " = " & Range("S4") & " Cases - " & Range("W4") & " % of Line Efficiency; " & Range("AC4") & " Minutes Down Time; " & Range("AE4") & " " & "Lbs - " & Range("AF4") & " % of Scrap." _
& Chr(13) & "Line " & Range("A5") & " - " & Range("B5") & " - " & Range("C5") & " = " & Range("S5") & " Cases - " & Range("W5") & " % of Line Efficiency; " & Range("AC5") & " Minutes Down Time; " & Range("AE5") & " " & "Lbs - " & Range("AF5") & " % of Scrap." _
& Chr(13) & "Line " & Range("A6") & " - " & Range("B6") & " - " & Range("C6") & " = " & Range("S6") & " Cases - " & Range("W6") & " % of Line Efficiency; " & Range("AC6") & " Minutes Down Time; " & Range("AE6") & " " & "Lbs - " & Range("AF6") & " % of Scrap." _
& Chr(13) & "Line " & Range("A7") & " - " & Range("B7") & " - " & Range("C7") & " = " & Range("S7") & " Cases - " & Range("W7") & " % of Line Efficiency; " & Range("AC7") & " Minutes Down Time; " & Range("AE7") & " " & "Lbs - " & Range("AF7") & " % of Scrap." _
& Chr(13) & "Line " & Range("A8") & " - " & Range("B8") & " - " & Range("C8") & " = " & Range("S8") & " Cases - " & Range("W8") & " % of Line Efficiency; " & Range("AC8") & " Minutes Down Time; " & Range("AE8") & " " & "Lbs - " & Range("AF8") & " % of Scrap."
olMail.Display
AppActivate "Microsoft Excel"
End Sub
<o> </o>
I have the following code that exports certain cell values, along with message from excel to outlook. It works great, provided that there are values in all those cells mentioned in the code. How do I re-write it to work even when some of the cells are blank?<o></o>
<o> </o>
Public Sub Test777()
Dim olApp As Object, olMail As Object
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(0)
olMail.To = "someone@yahoo.com"
olMail.Subject = "Mfg Shift Report"
olMail.body = "Line " & Range("A4") & " - " & Range("B4") & " - " & Range("C4") & " = " & Range("S4") & " Cases - " & Range("W4") & " % of Line Efficiency; " & Range("AC4") & " Minutes Down Time; " & Range("AE4") & " " & "Lbs - " & Range("AF4") & " % of Scrap." _
& Chr(13) & "Line " & Range("A5") & " - " & Range("B5") & " - " & Range("C5") & " = " & Range("S5") & " Cases - " & Range("W5") & " % of Line Efficiency; " & Range("AC5") & " Minutes Down Time; " & Range("AE5") & " " & "Lbs - " & Range("AF5") & " % of Scrap." _
& Chr(13) & "Line " & Range("A6") & " - " & Range("B6") & " - " & Range("C6") & " = " & Range("S6") & " Cases - " & Range("W6") & " % of Line Efficiency; " & Range("AC6") & " Minutes Down Time; " & Range("AE6") & " " & "Lbs - " & Range("AF6") & " % of Scrap." _
& Chr(13) & "Line " & Range("A7") & " - " & Range("B7") & " - " & Range("C7") & " = " & Range("S7") & " Cases - " & Range("W7") & " % of Line Efficiency; " & Range("AC7") & " Minutes Down Time; " & Range("AE7") & " " & "Lbs - " & Range("AF7") & " % of Scrap." _
& Chr(13) & "Line " & Range("A8") & " - " & Range("B8") & " - " & Range("C8") & " = " & Range("S8") & " Cases - " & Range("W8") & " % of Line Efficiency; " & Range("AC8") & " Minutes Down Time; " & Range("AE8") & " " & "Lbs - " & Range("AF8") & " % of Scrap."
olMail.Display
AppActivate "Microsoft Excel"
End Sub