Remove blank lines

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
780
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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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,214,948
Messages
6,122,420
Members
449,083
Latest member
Ava19

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