2014-01-20 96 views
0

我試圖從電子表格中獲取數據以顯示在電子郵件中。如果它全部連續,這將很容易。我要的是數據:VBA電子郵件多列

DspG DspN Comp PriSMTP Owner OwnerE 
A  M_N  C_N [email protected] O_N  [email protected] 
A  R_N  D_N [email protected] O_N  [email protected] 
A  N_N  E_N [email protected] O_N  [email protected] 
B  F_N  T_N [email protected] Dif_N [email protected] 
B  G_N  K_N [email protected] Dif_N [email protected] 
C  V_N  B_N [email protected] Oth_N [email protected] 

顯示DSPG,所有者和OwnerE只有一次,但是從DSPN,補償,PriSMTP獲得3行數據。在DspG等於B,然後是C的情況下重複此操作。一路向下A列。

非常感謝您提前尋求任何幫助/建議。

如果您感興趣的話,我使用的電子郵件程序是電子郵件是http://www.globaliconnect.com/excel/index.php?option=com_content&view=article&id=170:automate-outlook-using-vba-sending-email-from-excel-using-outlook&Itemid=473

回答

0

在您鏈接到的例子,我相信你應該能夠使用:

With miOL 
    .Subject = "Financial Analysis - 2012" 
    .Body = Range("A1:F7").Value 'Use the value of the range instead of explicitly stating a string 

如果將其作爲一行輸入或具有奇怪的格式,則應該可以使用For循環,並且每次輸入一行,然後輸入換行符和回車符。

+0

我似乎無法得到那個工作。我試過了幾個變化。如果我這樣做.Body = Range(「A1」)。Value,它會插入單個單元格的值。如果我把.Body = Range(「A1:A5」)。值,它總是空白。 – user3216727