Sub sum_values() Dim total As Double total = 0 For i = 2 To 10 total = total + Range("B" & i).Value Next i Range("B11").Value = total End Sub
Sub copy_paste() Range("A1").Copy Range("B1") End Sub
Sub filter_data() ActiveSheet.Range("$A$1:$D$20").AutoFilter Field:=1, Criteria1:="Valor1" End Sub
Sub insert_row() Rows("3:3").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove End Sub
Sub sort_data() Range("A2:D11").Sort Key1:=Range("B2"), Order1:=xlDescending, Header:=xlYes End Sub
Sub format_cells() Range("A1:D11").NumberFormat = "#,##0.00" End Sub
Sub protect_sheet() ActiveSheet.Protect Password:="senha" End Sub
Sub unprotect_sheet() ActiveSheet.Unprotect Password:="senha" End Sub
Sub create_chart() ActiveSheet.Shapes.AddChart2(227, xlLineMarkers).Select ActiveSheet.ChartObjects("Gráfico 1").Activate ActiveChart.SetSourceData Source:=Range("A2:D11") End Sub
Sub sendemailattachment() Dim OutlookApp As Object Dim OutlookMail As Object Set OutlookApp = CreateObject("Outlook.Application") Set OutlookMail = OutlookApp.CreateItem(olMailItem) With OutlookMail .To = "emaildestinatario" .Subject = "Assunto do e-mail" .Body = "Corpo do e-mail" .Attachments.Add ("caminhodo_anexo") .Display End With Set OutlookMail = Nothing Set OutlookApp = Nothing End Sub