Remove blank lines

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
781
Office Version
  1. 365
I have form and code below, how can I modify the code automatically remove blank lines that I don't use when emaling,

Remittance.jpg


code:

VBA Code:
Sub Send_Range()
   ' Select the range of cells on the active worksheet.
   ActiveSheet.Range("A1:D31").Select
   
   ' Show the envelope on the ActiveWorkbook.
   ActiveWorkbook.EnvelopeVisible = True
   
   ' Set the optional introduction field thats adds
   ' some header text to the email body. It also sets
   ' the To and Subject lines. Finally the message
   ' is sent.
   With ActiveSheet.MailEnvelope
      .Introduction = ActiveSheet.Range("APPLY") '"Please apply the payment to our account or invoice(s) listed below."
      .Item.To = ActiveSheet.Range("B4")
      .Item.CC = ActiveSheet.Range("B5") & ";" & "navigata.ap@distributel.ca"
      .Item.Subject = ActiveSheet.Range("EFT") '"Wire Remittance $"
      .Item.body = ActiveSheet.Range("EFT")
      .Item.Display
      
   End With
   
End Sub
 

Attachments

  • Remittance.jpg
    Remittance.jpg
    48.6 KB · Views: 1

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Would hiding the rows work ?

below ActiveSheet.Range("A1:D31").Select
VBA Code:
Dim cel As Range
For Each cel In Range("A10:A31")
    If cel = "" Then cel.EntireRow.Hidden = True
Next
 
Upvote 0
Just spotted that I omitted ActiveSheet.Range("A10:A31") in post#2 :oops:

Would selecting a different range work ?
(I assume that there is nothing else in the range apart from the space for more items)

Replace
VBA Code:
ActiveSheet.Range("A1:D31").Select
With
VBA Code:
ActiveSheet.Range("A1:A" & ActiveSheet.Range("A8").End(xlDown).Row).Resize(, 4).Select
 
Upvote 0

Forum statistics

Threads
1,215,459
Messages
6,124,944
Members
449,198
Latest member
MhammadishaqKhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top