Forum Discussion
Value from Cell to Autofill Email
I'm going to start by saying I'm a total noob on excel so apologies if this is a dumb question.
Basically I'm trying to make a tool where you fill in a form, click a button and the data from the table fills gaps in the body of the email.
For example: If you put your name is Lyle on the form, it'll start the email as "Hello Lyle," - if that makes sense.
I've got it all working apart from the email body itself. I'm trying to put the cells in but it's typing them out verbatim and I'm unsure how to continue.
Example:
emailItem.Body = "Hello," & vbNewLine & vbNewLine & "Please be advised quote number:" & "D4" & "has been accepted in our system"
The idea is to have whatever is in cell D4 going there but instead it's just putting the cell name (D4). Any help is very welcome, I'm trying to learn so if there's an easier way let me know!
7 Replies
That would be
emailItem.Body = "Hello," & vbNewLine & vbNewLine & "Please be advised quote number: " & Range("D4").Value & " has been accepted in our system"
Note that I added spaces in the strings before and after the value of D4.
If the name Lyle (or whatever) is in E4, it could be
emailItem.Body = "Hello " & Range("E4").Value & "," & vbNewLine & vbNewLine & "Please be advised quote number: " & Range("D4").Value & " has been accepted in our system"
- Edg38426Copper Contributor
Is it possible to use a worksheet event (such as entering a date into a cell) to then use a dynamic reference (rather than an absolute "D4" ref) to send an email unique to a particular table row?
Let's say you have dates in B4:B50, and you enter a date in B2.
The code could then search for that date in B4:B50 and look up the value in column D in the row where the date is found.
- ElctenCopper ContributorI'll give that a try! Thank you so much for your help 🙂