我想从我的工作表添加一个范围到生成的电子邮件的正文但是vba。我一直都会收到错误,感谢任何帮助
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
答案 0 :(得分:3)
您的错误与您声明范围的方式有关。
Set
End(xlDown)
无法作为字符串传递Option 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
一旦设法获得了正确的范围,就会更容易 - Paste specific excel range in outlook