Excel 如何在每张工作表中使用vba自动创建数据电子邮件模板,并将特定数据发送给个人

Excel 如何在每张工作表中使用vba自动创建数据电子邮件模板,并将特定数据发送给个人,excel,vba,Excel,Vba,我喜欢运行vba代码,如果可能的话,它会在每张图纸中自动执行以下操作: 我有一本40页的excel手册,每一页都是我们商店的销售额 A列为产品类型,只有5种类型 B栏是我们出售它的美元价值 C列为产品upc代码 我希望vba创建一个电子邮件模板,该模板将 那家商店的总销售额 显示每种类型的总销售量的图表 显示每种类型的总销售额的图表 upc代码列表,分为5种产品类型 通过电子邮件发送到商店,表名是商店名称,我在另一张表中有每个商店的电子邮件地址。。我将每天收到报告以下是一些可能对您有所帮助的

我喜欢运行vba代码,如果可能的话,它会在每张图纸中自动执行以下操作:

我有一本40页的excel手册,每一页都是我们商店的销售额

A列为产品类型,只有5种类型

B栏是我们出售它的美元价值

C列为产品upc代码

我希望vba创建一个电子邮件模板,该模板将

  • 那家商店的总销售额
  • 显示每种类型的总销售量的图表
  • 显示每种类型的总销售额的图表
  • upc代码列表,分为5种产品类型

通过电子邮件发送到商店,表名是商店名称,我在另一张表中有每个商店的电子邮件地址。。我将每天收到报告

以下是一些可能对您有所帮助的代码:

我来准备邮件

    type sale price    UPC code    Profit
      A    25         15116841635   2
      B    20         131313313 3   6 
      C    15          151651651    4
      D    10         55615613      3
      E    29         22222222      4
      A    22        1123333        4.4
      C    25        351313131     4.8
      D    25        131313131     5.2
      C    23         31331333     5.6
      E     23       51511352       6
      A     30       132323232     6.4
      B     80      3233213213     6.8
      A     47      3131311313     7.6


        Date        

        Total Sales (total dollar value)    
        Total units     "(Total units, each line is one unit)"  
        Total profit        

        A   (total units in A)  (total profit from A) 
        B   (total units in B)  (total profit from b)
        C            --                --
        D            --                 
        E            --                 --


                         Product A      
               Upc code    sale price   profit

              list broken by each product in A catagory     

                         Product B      
               Upc code   sale price    profit

                    and other types (max 6 - 10 ) 



              each sheet will have no more than 200 products daily so 
              i am thinking i can use specific cells like A200 as a 
              specific reference to start, i am not gonna have more than 
              200 lines. i am looking for vba code to put data into  
             above format, then  look for email address in another sheet 
             using sheet name and then email above created format only 
             to that person via outlook, 

请在这里添加一些代码和工作簿,因为您的“问题”太广泛了,不容易知道您是否已经做了一些事情。我正在添加一些对您有用的东西,但是您好,我已经在我的计算机中创建了一个示例表,如何将excel文件附加到此论坛。。感谢您的快速回复,我是vba新手。我得到了一张包含所有门店数据的工作表。到目前为止,我得到了分隔每个门店销售的代码,并使用该门店名称创建了一张新工作表
Sub EnvoiMail(Subject As String, Destina As String, Optional CCdest As String, Optional CCIdest As String, Optional BoDyTxt As String, Optional NbPJ As Integer, Optional PjPaths As String)
  Dim MonOutlook As Object
  Dim MonMessage As Object
  Set MonOutlook = CreateObject("Outlook.Application")
  Set MonMessage = MonOutlook.CreateItem(0)

  Dim PJ() As String
  PJ() = Split(PjPaths, ";")

  With MonMessage
      .Subject = Subject      ' "Je suis content"
      .To = Destina           ' "marcel@machin.com;julien@chose.com"
      .CC = CCdest            ' "chef@machin.com;directeur@chose.com"
      .BCC = CCIdest          ' "un.copain@supermail.com;une-amie@hotmail.com"
      .BoDy = BoDyTxt
        If PjPaths <> "" And NbPJ <> 0 Then
            For i = 0 To NbPJ - 1
                'MsgBox PJ(I)
              .Attachments.Add PJ(i)      '"C:\Mes Documents\Zoulie Image.gif"
            Next i
        End If
      .Display
  End With

  Set MonOutlook = Nothing
End Sub
Sub Graph()

Dim Gr As Chart

        Set Gr = ActiveWorkbook.Charts.Add
            With Gr
            'Définition des données sources du graphique
            .SetSourceData Source:=Range(Sheets(Src_Name).Cells(2, 1), Sheets(Src_Name).Cells(20, 5)), PlotBy:=xlRows
            'Type de graphique
            .ChartType = xlXYScatterSmooth
            'Place
            .Location Where:=xlLocationAsNewSheet, Name:=NewSheetName
            'Titre
            .HasTitle = True
            .ChartTitle.Characters.Text = "Chart Title"
            'Séries de données
            .SeriesCollection.NewSeries
            .SeriesCollection(1).Values = Range(Sheets(Src_Name).Cells(2, 2), Sheets(Src_Name).Cells(20, 5))
            .SeriesCollection(1).XValues = Range(Sheets(Src_Name).Cells(2, 1), Sheets(Src_Name).Cells(20, 1))
            .SeriesCollection(1).AxisGroup = 1
            .SeriesCollection(1).Name = "MTTF Calendaire"
            .SeriesCollection.NewSeries
            .SeriesCollection(2).Values = Range(Sheets(Src_Name).Cells(2, 2), Sheets(Src_Name).Cells(20, 5))
            .SeriesCollection(2).XValues = Range(Sheets(Src_Name).Cells(2, 1), Sheets(Src_Name).Cells(20, 1))
            .SeriesCollection(2).Name = "MTTR"
            .SeriesCollection(2).AxisGroup = 2
            .SeriesCollection(3).Delete
                        'épaisseur de la ligne tracée
                        .SeriesCollection(i).Format.Line.Weight = 1
                        'couleur des series
                        '.SeriesCollection(i).Format.Line.ForeColor.RGB = RGB(int1 as integer, int1 as integer, int3 as integer) ' pour une ligne
                        '.SeriesCollection(i).Format.Fill.ForeColor.RGB = RGB(int1 as integer, int1 as integer, int3 as integer) ' pour une area
            'Paramétrages des axes
            .Axes(xlCategory, xlPrimary).HasTitle = True
            .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Age"
            .Axes(xlValue, xlPrimary).HasTitle = True
            .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Heures"
            .PlotArea.Interior.ColorIndex = 2
            .Axes(xlValue).MajorGridlines.Border.LineStyle = xlDot
            .ChartArea.Font.Size = 14
            .Deselect
            End With

            'Placement de légende
            With ActiveChart.Legend
                .Left = 350
                .Top = 75
            End With
            'Placement des la zone de tracage
            With ActiveChart.PlotArea
                .Width = 550
                .Height = 350
            End With



'faire le ménage
Set Gr = Nothing



End Sub