Beruflich Dokumente
Kultur Dokumente
Sintaxe
Sub <nome_da_macro> ()
<Programa>
End Sub
<Programa>
End Function
Primeiro Programa
Sub MacroApp()
MsgBox "Olá Mundo"
End Sub
Propriedades
Sub propriedades()
Range("a1").Value = 20
Range("a1").Font.Name = "Comic Sans MS"
Range("a1").Font.Size = 25
End Sub
Sub calcBasico()
Range("b2") = 30
Range("b3") = 80
Range("b5") = Range("b2") + Range("b3")
End Sub
Funções
Selecionar Células
Sub selecionaCelulas()
'Range("a1").Select
Range("a1:c8").Select
End Sub
Sub selecionaIntervaloComCell()
Range(Cells(1, 1), Cells(5, 6)).Select
End Sub
Sub selecionaColuna()
Columns(1).Select
End Sub
Sub selecionaLinha()
Rows(1).Select
End Sub
Sub celulaAtiva()
ActiveCell.EntireColumn.Select
' ActiveCell.EntireRow.Select
End Sub
Sub SelecionaPlanilha()
'Worksheets("Planilha1").Select
'Sheets("Planilha1").Select
Sheets(1).Select
End Sub
Sub selecionaVariasPlanilhas()
Sheets(Array(1, 2)).Select
End Sub
Sub selecionaArquivo()
Workbooks("Pasta1").Select
End Sub
Sub TesteActiveCell()
Range("a1:a10").Select
'Range("a3").Activate
ActiveCell.Value = 30
End Sub
Sub selecionaXl()
Range("d7").End(xlDown).Select
'Range("d7").End(xlUp).Select
'Range("d7").End(xlToLeft).Select
'Range("d7").End(xlToRight).Select
'Selection.End(xlUp).Select
End Sub
Sub selecionaXlRange()
'Range("D6", Selection.End(xlUp)).Select
'Range("D6", Selection.End(xlToLeft)).Select
'Range(Selection, Selection.End(xlToLeft)).Select
'Range(Selection.End(xlToLeft), Selection.End(xlUp)).Select
End Sub
Sub activeOffiset()
ActiveCell.Offset(3, 3).Select
ActiveCell.Offset(-3, -3).Select
Range("b2").Offset(2, 2).Select
End Sub
Sub copiarColar()
Range("b4:b6").Copy
Range("f4").Select
ActiveSheet.Paste
End sub
Sub copiarColuna()
Columns(1).Copy Destination:=Columns(7)
'Rows(1).Copy Destination:=Rows(7)
End Sub
Formatação
Sub Formatacao()
Range("G4").Font.Color = vbGreen
With ActiveCell
.Font.Color = vbRed
.Font.Italic = True
.Font.Bold = True
.Font.Underline = True
.Style = "Currency" ' Comma; Percent
.Font.Name = "Commic Sans MS"
.Interior.Color = vbBlack
End With
End Sub
Sub FormatacaoColorIndex()
ActiveCell.Font.ColorIndex = 36
End Sub
Fonte: https://img-
21.ccm2.net/0mXJDVpVL0VSFSUtfal8uj1qW4Q=/ed79a89ed7d94cc8b8c98f6310a1c3f3/ccm-
faq/leMItdLcG4ur5yFb3ozuV-codes-couleurs.png
Sub formatacaoBordas()
With Range("c12")
.Borders.LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeTop).Color = vbRed
.Borders(xlEdgeBottom).Color = vbYellow
.Borders(xlEdgeBottom).LineStyle = xlDot
End With
End Sub
Sub coresAbas()
With ActiveWorkbook.Sheets("Planilha2").Tab
.ThemeColor = xlThemeColorAccent1 ' 1 a 6
End With
End Sub
Filtros Básicos
Sub FilterAtivar2()
With Range("a1:g1")
Daniel Cavalcanti .AutoFilter field:=2, Criteria1:=">200"
TI – Artigos, códigos e muito
.AutoFilter field:=3, Criteria1:="<400"
mais
End With
End Sub
Sub resetFilter()
Home
ActiveSheet.ShowAllData
Sobre End Sub
Contato
Atividades
Pesquisar … 1. Crie um programa que execute a seguinte rotina
1. Selecione a célula A1, atribua o valor Nome em negrito e borda
inferior
2. Selecione a célula B1, atribua o valor Salário em negrito e borda
CATEGORIAS
inferior
Angular 3. Selecione a célula A2, Atribua o valor Ana Maria na cor azul
Aulas 4. Selecione a célula B2, Atribua o valor 3000 no formato moeda na
cor vermelho
Banco de Dados
5. Copie o intervalo A1:B2, cole na célula D1
Design de Interface 2. Baixe a planilha5
Engenharia de Software 1. Formate o cabeçalho em negrito, cor azul, tamanho 16, Fonte Arial
Black
Excel
2. Formate os valores em moeda
Excel com BI
3. Calcule o total
Excel VBA
HTML
Java Web
PHP
5. IF Else SEGUINTE