Hi all,
I've learnt everything I know about VBA (not a lot) from Google it's left me stumped on my latest attempt! I can see some suggested solutions but none of them really fit my scenario!
I have a worksheet that details team performance across columns A - AH. The columns of relevance for this query are C, D, O and V - O being where I plan to make my selection of cells (likely 6 cells/rows at a time) to enable the macro.
I have a code that I have attached to a button to generate an email deigned as a business update. I've covered almost everything I need including inserting an image, counting active cells, summing offset active cells etc but I'm struggling to directly transpose offset rages into the text of the email.
Essentially, I have three columns that I need to insert the data (they're names) as text values that I can format into a horizontal list.
Here is a sanitized example of my code.
Any suggestions (in their simplest form as I’m extraordinarilysurprised I’ve made it this far on my knowledge!) would be greatly appreciated!
Thanks
I've learnt everything I know about VBA (not a lot) from Google it's left me stumped on my latest attempt! I can see some suggested solutions but none of them really fit my scenario!
I have a worksheet that details team performance across columns A - AH. The columns of relevance for this query are C, D, O and V - O being where I plan to make my selection of cells (likely 6 cells/rows at a time) to enable the macro.
I have a code that I have attached to a button to generate an email deigned as a business update. I've covered almost everything I need including inserting an image, counting active cells, summing offset active cells etc but I'm struggling to directly transpose offset rages into the text of the email.
Essentially, I have three columns that I need to insert the data (they're names) as text values that I can format into a horizontal list.
Here is a sanitized example of my code.
Code:
[FONT=Calibri][SIZE=3][COLOR=#000000]Sub Internal_RoundUp()[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Dim xOutApp As Object[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Dim xOutMail As Object[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Dim xMailBody As String[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Set xOutApp =CreateObject(""Outlook.Application"")[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Set xOutMail =xOutApp.CreateItem(0)[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]xMailBody = [/COLOR][/SIZE][SIZE=3][COLOR=#000000]"<imgsrc='cid:test.jpg' height="170" "="" &="" "width="650">
" & "
" & "
"&</imgsrc='cid:test.jpg'>[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]"[B]" & "Welcome to the " &format(dateadd("m",-1,date),"mmmm") & " edition ofthe Mid Market Sales Round Up" & [/B]" &"
" & "
" & "This month hasseen " & selection.cells.count & " deals complete" &"
" & "
" &[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[COLOR=red][FONT=Calibri][SIZE=3][INSERT NAMES [/SIZE][SIZE=3]offset C (-12)] [/SIZE][/FONT][/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]& " are our newest clients and have a total product value of" & "[B]" & "£" &application.worksheetfunction.sum(offset(selection,-1)) &"[/B]" & " including prod 1 totalling " &"[B]" & "£" &application.worksheetfunction.sum(offset(selection,-4)) &"[/B]" & " and prod 2 at " &"[B]" & "£" &application.worksheetfunction.sum(offset(selection,-2)) &"[/B]" & ". That equates to " &"[B]" & "£" &application.worksheetfunction.sum(selection) & "[/B]" &" PFI." & "
" & "
"& "Our BD's, " & [/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[COLOR=red][FONT=Calibri][SIZE=3][INSERT NAMES [/SIZE][SIZE=3]offset D (-11)][/SIZE][/FONT][/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]& " would like toextend their thanks to " & "[B]" & [/B][/COLOR][/SIZE][/FONT][B]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[COLOR=red][FONT=Calibri][SIZE=3][INSERT THANK YOU NAMES [/SIZE][SIZE=3]offset [/SIZE][SIZE=3]V(+7)] [/SIZE][/FONT][/COLOR]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]& "[/COLOR][/SIZE][/FONT][/B][SIZE=3][COLOR=#000000]" & " for their help in gettingthese deals over the line ." [/COLOR][/SIZE]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]On Error Resume Next[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]With xOutMail[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000].To =""person@business.co.uk""[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000].CC =""""[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000].BCC =""""[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000].Subject =""Mid Market Round up!""[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000].BodyFormat =olFormatHTML[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000].Attachments.Add""V:\Sales\Deal Alerts\Images\test.jpg"", olByValue, 0[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]sImgName =""test.jpg""[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000].htmlbody = xMailBody[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000].Display[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]End With[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]On Error GoTo 0[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Set xOutMail = Nothing[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Set xOutApp = Nothing[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]
[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]End Sub[/COLOR][/SIZE][/FONT]
Any suggestions (in their simplest form as I’m extraordinarilysurprised I’ve made it this far on my knowledge!) would be greatly appreciated!
Thanks