Reputation: 121
I would like to add a range from my sheet to the body of an email which is generated but vba. I keep getting errors and any help would be appreciated
myRange = Range("A12:A12.End(xlDown)").SpecialCells(xlCellTypeVisible)
'This will extract the info for the worksheet
'This extracts the subject title from the worksheet
EmailSubject = "STOCKS " & Type1 & " - " & Left(Trade, 6) & " [" & _
Range("A12").Value & "/" & Range("A12").End(xlDown).Value _
& "]: % at %"
Body = "<b>" & Range("A8").Value & "</b><br/>" & Range("A9").Value & "<br/>" _
& Range("A10").Value & "<br/><br/>" _
& myRange
Upvotes: 0
Views: 189
Reputation: 43585
Your error is in the way you are declaring the range.
Set
End(xlDown)
cannot be passed as a StringOption Explicit
Sub TestMe()
Dim myRange As Range
Dim firstCell As Range
Dim lastCell As Range
Set firstCell = Range("A12")
Set lastCell = firstCell.End(xlDown)
Set myRange = Range(firstCell, lastCell).SpecialCells(xlCellTypeVisible)
End Sub
Once you manage to have the correct range, it would be easier - Paste specific excel range in outlook
Upvotes: 3