Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default pasting cell range in an email

This is the code to take a cell range and pastes it in an
email's subject line and body. The flaw is that I will
have manually update the cell range to get the last
filled row

I like to select a wider cell range so the macro would
paste the last filled rowin that range. Any suggestionse
will be greatly appreciated.

Sub Mail_Text_in_Body()
Dim msg As String, cell As Range
Dim Recipient As String, Subj As String, HLink As
String
Dim Recipientcc As String, Recipientbcc As String

Recipient = ""
Recipientcc = ""
Recipientbcc = ""
'Subj = "test"

msg = Sheets("PIVNUMS").Range("A18").Value & " - Piv
#s "
For Each cell In Sheets("PIVNUMS").Range("B18:AG18")
msg = msg & cell
Next cell
msg = WorksheetFunction.Substitute(msg, vbNewLine, "%
0D%0A")

HLink = "mailto:" & Recipient & "?" & "subject=" &
msg & "&"
'HLink = HLink & "subject=" & Subj & "&"
HLink = HLink & "body=" & msg

ActiveWorkbook.FollowHyperlink (HLink)
'Application.Wait (Now + TimeValue("0:00:03"))
'Application.SendKeys "%s"
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default pasting cell range in an email

Sub Mail_Text_in_Body()
Dim msg As String, cell As Range
Dim Recipient As String, Subj As String, HLink As
String
Dim Recipientcc As String, Recipientbcc As String

Recipient = ""
Recipientcc = ""
Recipientbcc = ""
'Subj = "test"

msg = Sheets("PIVNUMS").Range("A18").Value & " - Piv
#s "
lastRow = Sheets("PIVNUMS").Range("B65536").End(xlup).Row
For Each cell In Sheets("PIVNUMS").Range("B" & lastRow & ":AG" &
lastRow)
msg = msg & cell
Next cell
msg = WorksheetFunction.Substitute(msg, vbNewLine, "%
0D%0A")

HLink = "mailto:" & Recipient & "?" & "subject=" &
msg & "&"
'HLink = HLink & "subject=" & Subj & "&"
HLink = HLink & "body=" & msg

ActiveWorkbook.FollowHyperlink (HLink)
'Application.Wait (Now + TimeValue("0:00:03"))
'Application.SendKeys "%s"
End Sub

"alldreams" wrote in message
...
This is the code to take a cell range and pastes it in an
email's subject line and body. The flaw is that I will
have manually update the cell range to get the last
filled row

I like to select a wider cell range so the macro would
paste the last filled rowin that range. Any suggestionse
will be greatly appreciated.

Sub Mail_Text_in_Body()
Dim msg As String, cell As Range
Dim Recipient As String, Subj As String, HLink As
String
Dim Recipientcc As String, Recipientbcc As String

Recipient = ""
Recipientcc = ""
Recipientbcc = ""
'Subj = "test"

msg = Sheets("PIVNUMS").Range("A18").Value & " - Piv
#s "
For Each cell In Sheets("PIVNUMS").Range("B18:AG18")
msg = msg & cell
Next cell
msg = WorksheetFunction.Substitute(msg, vbNewLine, "%
0D%0A")

HLink = "mailto:" & Recipient & "?" & "subject=" &
msg & "&"
'HLink = HLink & "subject=" & Subj & "&"
HLink = HLink & "body=" & msg

ActiveWorkbook.FollowHyperlink (HLink)
'Application.Wait (Now + TimeValue("0:00:03"))
'Application.SendKeys "%s"
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
pasting an email into a cell in excel pinky[_2_] Excel Discussion (Misc queries) 1 November 5th 07 09:29 AM
Help with EMAIL coping and pasting patti Excel Discussion (Misc queries) 0 March 6th 07 10:12 PM
pasting non-contiguous range of cells to new row, same cell locati Not excelling at macros New Users to Excel 3 April 4th 06 08:57 PM
pasting a range of info based on the value in a particular cell vsmith Excel Discussion (Misc queries) 0 February 10th 06 10:57 PM
Pasting data top 1st empty cell in range wfcmark Excel Discussion (Misc queries) 4 December 8th 05 10:46 AM


All times are GMT +1. The time now is 08:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"