Saving a .csv will save all columns in the sheet, since 5 is in several columns over, the comma separator will include those blank cells.
If you are just using .csv so you have something to paste onto the outlook email, you can paste the specific range in excel.
Check it out.
Sub CopyRngToOutlook()
Dim doc As Object
Dim LstRw As Long
Dim rng As Range, rng2 As Range, st As String, x
Dim sh As Worksheet
Set sh = Sheets("Sheet2")
With sh
LstRw = .ListObjects("Table13").Range.Columns(1).Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Set rng = .Range("A2:J" & LstRw)
st = "Total Records - " & .Range("J" & LstRw).Value
End With
x = Len(st)
With CreateObject("Outlook.Application").CreateItem(0)
.Display
.body = st
Set doc = .GetInspector.WordEditor
rng.Copy
doc.Range(x, x).Paste
.To = "someone@somewhere.com"
.Subject = "Send Email Body"
Application.CutCopyMode = 0
End With
End Sub
Once you have formatted your cells it will end up like this:
------------------------------------------------------------------------------
2022-12-25_5-34-19.jpg
Bookmarks