-
Gravando
-
Movimento Relativo
-
Botão
- Referência Relativa
-
Editando
-
Editor
- Tools > Macro > Visual Basic Editor
-
Depurar
-
Passo-a-passo
- Debug > Step Into
-
Ponto de Interrupção
- Debug > Toggle Breakpoint
-
Programando
-
Inserir
-
Módulo
- Insert > Module
-
Comentário
- '
-
Excluir
-
Módulo
- File > Remove Módulo xx
-
Objetos
-
Application
-
Sintaxe
-
Application.XXX
- =XXX
-
Propriedade
-
Caption
- = "Controle de Vendas"
- = Empty
- Sem argumento, captura o título
-
ActiveCell
- ActiveCell.value
- = 45
-
ActiveWindow
- = "Mês de Janeiro"
-
ScreenUpdating
- = False
-
DisplayAlerts
- = False
-
EnableCancelKey
- = x1Disabled
-
DataEntryMode
- =x1Strict
-
WindowState
- =x1Maximized
-
Dialogs
- Application.Dialogs(Nome da Caixa).show
- x1DialogFormatFont
- x1DialogPatterns
-
Método
- Quit
- Calculate
-
Error
- On Error goto X
-
Atribuir Teclas
- OnKey(Key,Procedimento)
- OnKey "{F8}" , "Cadastrar"
-
Workbooks
-
Sintaxe
- Workbooks("XXX.xls").XXX
-
Propriedade
-
Name
- ActiveWorkbook.name
- Fullname
- Saved
-
Itens Janela
- DisplayGridlines
- DisplayOutline
- DisplayHorizontalScrollbar
- DisplayVerticalScrollbar
- DisplayWorkbookTabs
- DisplayAutomaticPageBreaks
- DisplayStatusBar
-
Método
-
Close
- SaveChanges
- FileName
- RouteWorkbook
-
Open
- Workbooks.Open Filename:="C:\Teste.xls", password:="Segredo"
- Save
-
Protect
- Password
- Structure
- Windows
-
Unprotect
- Password
-
Worksheets
-
Sintaxe
- Worksheets("XXX.xls").XXX
-
Propriedade
- Count
-
Visible
- = False
- = True
-
ScrollArea
- = "A1:J10"
-
EnableSelection
- = x1NoSelection
- = x1NoRestrictions
- = x1UnlockedCells
- Selection
-
Offset
- Offset(0,-2)
-
End
- End(Direção)
- x1Up
- x1Down
- x1ToLeft
- x1ToRight
- ActiveSheet
-
Row
- ActiveCell = ActiveCell.Row
- Row("2:4").Insert
- RowHeight = xx
-
Column
- ActiveCell = ActiveCell.Column
- Columns.Delete
- ColumnWidth = xx
-
EntireRow
- Selection.EntireRow.Insert
-
EntireColumn
- Selection.EntireColumn.Insert
-
Método
-
Add
- Worksheets.Add Worksheets("teste"), , 2
- Before
- After
- Count
- Type
- x1WordSheet
- x1Excel4MacroSheet
- Delete
-
Copy
- Before
- After
-
Move
- Before
- After
- Select
-
Protect
- Password
- DrawingObjects
- Contents
- Scenarios
- UserInterfaceOnly
- Unprotect
-
Range
-
Sintaxe
- Range("XXX:YYY").XXX
-
Propriedade
-
Value
- = "País"
- Range("Dados,Valores").Value = "17"
- Row
- Column
-
Name
- ="Valores"
-
Font
- Range(Cells(VarLinha,VarColuna), ActiveCell).Font.ColorIndex = 3
- Name
- FontStyle
- Bold
- Italic
- Size
- Strikethrough
- Superscript
- Subscript
- Underline
- x1UnderlineStyleNone
- x1UnderlineStyleSingle
- x1UnderlineStyleSingleAccounting
- x1UnderlineStyleDouble
- x1UnderlineStyleDoubleAccounting
- x1UnderlineStyleNone
-
Interior
- Range("A1").Interior.ColorIndex = 15
-
ColorIndex
- <html><img src="../../My Pictures/Paleta de Cores.JPG">
- = Número_Paleta_Cores
-
Alignment
- HorizontalAlignment
- x1General
- x1Left
- x1Right
- x1Fill
- x1Justify
- x1CenterAcrossSelection
- VerticalAlignment
- x1Bottom
- x1Top
- x1Center
- x1Justify
- WrapText
- = True
- = False
- Orientation
- - 90 ... + 90
- ShrinkToFit
- = True
- = False
-
Borders
- Index
- Sintaxe
- Borders(xx)
- x1DiagonalDown
- x1DiagonalUp
- x1EdgeLeft
- x1EdgeRight
- x1EdgeTop
- x1EdgeBottom
- x1InsideVertical
- x1InsideHorizontal
- LineStyle
- x1Continuous
- x1Dash
- x1DashDot
- x1DashDotDot
- x1Dot
- x1Double
- x1SlantDashDot
- x1LineStyleNone
- x1None
- Weight
- x1HairLine
- x1Thin
- x1Medium
- x1Thick
-
BorderAround
- (LineStyle, Weight, ColorIndex, Color)
-
NumberFormat
- Sequência
- Número Positivo; Número Negativo; Zero; Texto
- = "#,##0.00; (#,##0.00)"
- = "dd - dddd/mmmm/yyyy"
- = "General"
-
MergeCells
- = True
- = False
-
Cells
- Cells(Linha,Coluna).XXX
-
Método
-
Select
- Range("D5").Range("A1:C1").Select
-
Copy
- Range("B2,ActiveCell:E14").copy Range ("G7")
- Cut
- Clear
- Clear Contents
-
Delete
- (x1ShiftUp)
- (x1ShiftToLeft)
-
Insert
- (x1ShiftDown)
- (x1ShiftToRight)
-
Sort
- Sort(Key1:=Range("A1"), Order1:=x1Ascending, ...)
- Key1
- Order1
- x1Ascending
- x1Descending
- Key2
- Type
- Order2
- x1Ascending
- x1Descending
- Key3
- Order3
- x1Ascending
- x1Descending
- Header
- x1Yes
- x1No
- x1Guess
- OrderCustom
- MatchCase
- True
- False
- Orientation
- x1TopToBottom
- x1LeftToRight
- SortMethod
- x1Syllbary
- x1CodePage
-
Variáveis
-
Sintaxe
-
Declaração
- Dim Nome_Cliente as String
-
Utilização
- variável_X = inputbox "teste"
-
Instrução
- Dim
- Private
- Public
-
Set
- Variável_x = Range("A1")
- Variável_x = Nothing
-
Tipos
- Byte
- Boolean
- Integer
- Long
- Single
- Double
- Currency
- Decimal
- Date
- String
- Variant
-
Object
- Utilizar Set em seguida
- Definido pelo Usuário
-
Requerer Declaração
-
Tools > Options > Editor
- Require Declaration Variable
-
Proteção do Projeto
-
Ferramentas > Propriedades de VBA Project > Proteção
- Bloquear projeto para exibição
-
Erros
-
Depurar
- F8
-
Variável
-
Verificar Valor
- Para o mouse em cima
- Adicionar Inspeção de Variáveis
-
Exibir
-
Exibir > Depuração Imediata
- ? + código de verificação
-
On Error
- GoTo
- Resume Next
- Err.Number
-
Barras de Ferramentas
- CommandBars.Add Name:="Controle", Position:=msoBarTop
-
Método
-
Add
- Name
-
Position
- msoBarLeft
- msoBarRight
- msoBarTop
- msoBarBottom
- msoBarFloating
- msoBarPopUp
-
MenuBar
- True
- False
-
Temporary
- True
- False
-
Visible
- True
- False
-
Controls
-
Add
- Type
- msoControlButton
- msoControlEdit
- msoControlDropdown
- msoControlComboBox
- msoControlPopup
- ID
- 2949
- 2950
- Parameter
- Before
- Temporary
- True
- False
- Caption
- OnAction
-
Enabled
- True
- False
-
Style
- msoButtonCaption
- Delete
- Delete
- Reset
-
Protection
- msoBarNoCustomize
- msoBarNoResize
- msoBarNoMove
- msoBarNoChangeVisible
- msoBarNoChangeDock
- msoBarNoVerticalDock
- msoBarNoHorizontalDock
- msoBarNoProtection
- Count
-
BuiltIn
- True
- False
-
Enabled
- True
- False
- Name
-
Auto Macros
- Sub Auto_Open ( )
- Sub Auto_Close ( )
-
Não Executar
- Pressionar SHIFT
-
Eventos
-
Planilha
- Activate
- Deactivate
- Change
- BeforeDoubleClick
- BeforeRightClick
- Calculate
- FollowHyperLink
- SelectionChange
-
Pasta Trabalho
- BeforeClose
- Open
- BeforePrint
- BeforeSave
- NewSheet
- SheetBeforeDoubleClick
- SheetBeforeRightClick
- SheetCalculate
- SheetChange
- SheetDeactivate
- SheetFollowHyperlink
- SheetSelectionChange
- WindowActivate
- WindowDeactivate
- WindowResize
- Registros
-
Formulários
- Insert > UserForm
-
Propriedades
- Name
- Accelerator
- AutoSize
- AutoTab
- AutoWordSelect
- BackColor
- BackStyle
- BorderColor
- BorderStyle
- BoundColumn
- Cancel
- Caption
- ColumnCount
- ControlSource
- ControlTypeText
- Default
- Enabled
- Font
- ForeColor
- Height
- HideSelection
- IntegralHeight
- Left
- ListRows
- Locked
- MatchEntry
- MatchRequired
- Max
- MaxLenght
- Min
- MouseIcon
- MousePointer
- MultiLine
- PasswordChar
- Picture
- Source
- ScrollBars
- SmallChange
- SpecialEffect
- Style
- TabIndex
- TabKeyBehavior
- TabStop
- Text
- TextAlign
- TextColumn
- Top
- Visible
- Width
- WordWrap
-
Ferramentas
-
Barra
- Exibir > Barras de Ferramentas > UserForm
- Alinhamento
- Centralização
- Simetria
-
Caixa
- View > ToolBox
-
Controles
- Label
- lbl
- TextBox
- txt
- ComBox
- cmb
- ListBox
- lst
- CheckBox
- chk
- OptionButton
- opt
- Frame
- fram
- CommandButton
- cmd
- TabStrip
- tst
- Page
- pge
- ScrollBar
- scr
- SpinButton
- spi
- Image
- img
-
Código
-
Eventos
- AfterUpdate
- BeforeDragOver
- BeforeDropOrPaste
- BeforeUpdate
- Change
- Click
- DblClick
- DropButtonClick
- Enter
- Exit
- Initialize
- KeyDown
- KeyUp
- Layout
- MouseMove
- Resize
- SpinUp
- SpinDown
- Zoom
-
Intruções
-
Unload
- Unload Me
-
Tabulação
- Exibir > Ordem de Tabulação
-
Macro
- "frmTeste".show
-
Funções
-
InputBox
- vbCrLf
-
MsgBox
-
Botões
- vbOKOnly
- vbOKCancel
- vbAbortRetryIgnore
- vbYesNoCancel
- vbYesNo
- vbRetryCancel
-
Ícones
- vbCritical
- vbQuestion
- vbExclamation
- vbInformation
-
Padrão
- vbDefaultButton1
- vbDefaultButton2
- vbDefaultButton3
- vbDefaultButton4
-
Janela Restrita
- vbApplicationModal
- vbSystemModal
-
Matemáticas
- Abs
- Atn
- Cos
- Exp
- Fix
- Int
- Log
- Rnd
- Sgn
- Sin
- Sqr
- Tan
-
Financeiras
-
Rate
- PV(nper,pmt,pv[,fv][,Type],[guess])
-
Nper
- PV(Rate,pmt,pv[,fv][,Type])
-
Pmt
- PV(Rate,nper,pv[,fv][,Type])
-
Fv
- PV(Rate,nper,pmt[,fv][,Type])
-
Pv
- PV(Rate,nper,pmt[,fv][,Type])
- Type
-
Data e Hora
- Date
- Day
- Month
- Year
- Now
- DataSerial
- DataValue
- Weekday
- WeekdayName
- MonthName
- Hour
- Minute
- Second
- Time
- Timer
- TimeValue
- TimeSerial
-
Strings
- Left
- Right
- Mid
- Ucase
- Lcase
- Len
- Space
- Trim
- LTrim
- RTrim
- StrConv
- StrReverse
- String
-
Conversão
- CBool
- CByte
- CCur
- CDate
- CDbl
- CDec
- CInt
- CLng
- CStr
- CSng
- CVar
-
Planilha
- Application.WorksheetFunction.Nome da Função(Argumentos da Função)
-
Criar
- Function NomeFunção (Argumento1 As Tipo, Argumento2 As Tipo) As Tipo)
-
Local
- Assistente de Função > User Defined
-
Números
-
Formatação
- Format(Expressão,formato,Firstdayofweek,Firstweekofyear)
-
Operadores
-
Aritméticos
- ^
- *
-
Divisão
- /
-
\
- Retorna Inteiro
-
Mod
- Retorna Resto
- +
- -
-
Comparação
- <
- <=
- >
- >=
- =
- <>
- Is
- Like
-
Lógico
- And
- Or
- Not
- Eqv
- Imp
- Xor
-
Concatenação
- &
- +
-
Estruturas
-
Decisão
-
IF
- If condição Then Instruções End If
- If condição Then Instrução1 : Instrução2 : Instrução3 ...
- If Condição Then
Instruções para a condição verdadeira
Else
Instruções para a condição false
End If
- If Condição Then
Instruções para a condição verdadeira
Else If Condição Then
Instruções para If falso e Elseif verdadeiro
Else
Instruções para as condições anteriores Falsas
End If
- If condição then
Instruções para a condição verdadeira
If Condição Then
Instruções para a condição verdadeira
End If
End If
- If Condição And Condição 2 And Condição 3 ... Then
Instruções caso todas as condições sejam verdadeiras
Else
Instruções caso uma ou mais condições sejam falsas
End If
- If Condição1 Or Condição2 Or Condição3 ... Then
Instruções caso uma ou mais condições sejam verdadeiras
Else
Instruções caso todas as condições sejam falsas
End If
-
Select Case
- Select Case Expressão
Case Expressão1
Instruções1
Case Expressão2
Instruções2
Case Else
Instruções Else
End Select
-
Repetição
-
With
- With Selection.Font
.name = "Arial"
.Size = 14
End With
-
While
- Do While Condição
Instruções
Loop
- Do
Instruções
Loop While CondiÇão
- While Condição
Instruções
Wend
- Do Until Condição
Instruções
Loop
- Do
Instruções
Until Loop Condição
-
For
- For Contador = Valor Inicial To Valor Final Step
Instruções
Next
- For Each Elemento In Group
Instruções
Next