Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Sub Ingles_Portugues()
ActiveCell = ActiveCell.Formula
End Sub
Sub Portugues_Ingles()
ActiveCell = "'" & ActiveCell.Formula
End Sub
EXCLUIR LINHAS COM DETERMINADO CRITRIO
Sub EXCLUIR()
Dim lLin As Long
Application.ScreenUpdating = False
'.. ABA DETAILED HABITADO ..'
Sheets("ReF").Select
Range("A2").Select
With Sheets("ReF")
For lLin = .Cells(.Rows.Count, "AW").End(xlUp).Row To 2 Step -1
If .Cells(lLin, "G") = "GUI" Then .Rows(lLin).Delete
'Desafoga os processos pendentes do Windows a cada 100 linhas iteradas:
If lLin Mod 100 = 0 Then DoEvents
Next lLin
End With
End Sub
INSERIOR FRMULA NA LINHA
Sub InserirFormula()
Sheets("Detailed Comrcio").Select
Range("A2").Select
Dim lr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = 0
Range("AJ2").Formula = "=IF(C2="""","""",IF(C2=C3,""NO"",""SIM""))"
Range("AJ2").AutoFill Destination:=Range("AJ2:AJ" & lr)
Application.ScreenUpdating = 1
End Sub
COLA COM VALORES A LINHA COM FRMULA
Sub ColarValores ()
Range("AJ2:AJ10000").Copy
Range("AJ2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
Range("A2").Select
Application.CutCopyMode = False
End Sub
'......................................................................................................'
Application.StatusBar = "Processando, por favor aguarde..."
Application.Wait (Now + TimeValue("0:00:01"))
Application.ScreenUpdating = False
Application.ScreenUpdating = True
Application.StatusBar = "Importao finalizada com sucesso!"
CHAMAR USEFORM
Sub Formulario()
UseForm1.Show
End Sub
MsgBox "Planilha salva com sucesso Aparece a caixa com a mensagem ao finalizar Macro
Desbloquear Planilha
Sub DesprotegerPlanilhaAtiva() LIBERA PLANILHA COM SENHA
Dim i, i1, i2, i3, i4, i5, i6 As Integer, j As Integer, k As Integer, l As Integer, m As Integer, n As Integer
On Error Resume Next
For i = 65 To 66
For j = 65 To 66
For k = 65 To 66
For l = 65 To 66
For m = 65 To 66
For i1 = 65 To 66
For i2 = 65 To 66
For i3 = 65 To 66
For i4 = 65 To 66
For i5 = 65 To 66
For i6 = 65 To 66
For n = 32 To 126
ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
If ActiveSheet.ProtectContents = False Then
MsgBox "Planilha desbloqueada com sucesso"
Exit Sub
End If
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
End Sub
Inserir em MODULO
Option Explicit 'OCULTA OS BOTES MINIMIZAR / MAXIMIZAR E FECHAR DA BARRA DO EXCEL
'Sem as declaraes abaixo as macros para retirar e repor os botes no funcionar
Declare Function FindWindow32 Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer
Declare Function GetWindowLong32 Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Integer, ByVal nIndex As Integer) As Long
Declare Function SetWindowLong32 Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Integer, ByVal nIndex As Integer, _
ByVal dwNewLong As Long) As Long
Global Const GWL_STYLE = (-16)
Global Const WS_SYSMENU = &H80000
Sub RepoeXdaBarra()
Application.ScreenUpdating = True
Dim WindowStyle As Long
Dim hWnd As Integer
Dim WindowName As String
Dim Result As Variant
WindowName = Application.Caption
hWnd = FindWindow32(0&, ByVal WindowName)
WindowStyle = GetWindowLong32(hWnd, GWL_STYLE)
WindowStyle = WindowStyle Or WS_SYSMENU
Result = SetWindowLong32(hWnd, GWL_STYLE, WindowStyle)
'Fora a barra de ttulos a se atualizar, Retornando os Botes
Application.Caption = "PROJETO COMGS"
ActiveWindow.Caption = "BANCO DE HORAS"
End Sub
Sub RetiraXdaBarra()
Application.ScreenUpdating = False
Dim WindowStyle As Long
Dim hWnd As Integer
Dim WindowName As String
Dim Result As Variant
WindowName = Application.Caption
hWnd = FindWindow32(0&, ByVal WindowName)
WindowStyle = GetWindowLong32(hWnd, GWL_STYLE)
WindowStyle = WindowStyle And (Not WS_SYSMENU)
Result = SetWindowLong32(hWnd, GWL_STYLE, WindowStyle)
'Fora a barra de ttulos a se atualizar, Ocultando os Botes
Application.Caption = "PROJETO COMGS"
ActiveWindow.Caption = "BANCO DE HORAS"
End Sub
Function Extenso(nValor)
'
'escreve o valor em Reais por extenso
'
'
'Faz a validao do argumento
If IsNull(nValor) Or nValor <= 0 Or nValor > 9999999.99 Then
Exit Function
End If
'Declara as variveis da funo
Dim nContador, nTamanho As Integer
Dim cValor, cParte, cFinal As String
ReDim aGrupo(4), aTexto(4) As String
'Define matrizes com extensos parciais
ReDim aUnid(19) As String
aUnid(1) = "Um ": aUnid(2) = "Dois ": aUnid(3) = "Trs "
aUnid(4) = "Quatro ": aUnid(5) = "Cinco ": aUnid(6) = "Seis "
aUnid(7) = "Sete ": aUnid(8) = "Oito ": aUnid(9) = "Nove "
aUnid(10) = "Dez ": aUnid(11) = "Onze ": aUnid(12) = "Doze "
aUnid(13) = "Treze ": aUnid(14) = "Quatorze ": aUnid(15) = "Quinze "
aUnid(16) = "Dezesseis ": aUnid(17) = "Dezessete ": aUnid(18) = "Dezoito "
aUnid(19) = "Dezenove "
ReDim aDezena(9) As String
aDezena(1) = "Dez ": aDezena(2) = "Vinte ": aDezena(3) = "Trinta "
aDezena(4) = "Quarenta ": aDezena(5) = "Cinquenta "
aDezena(6) = "Sessenta ": aDezena(7) = "Setenta ": aDezena(8) = "Oitenta "
aDezena(9) = "Noventa "
ReDim aCentena(9) As String
aCentena(1) = "Cento ": aCentena(2) = "Duzentos "
aCentena(3) = "Trezentos ": aCentena(4) = "Quatrocentos "
aCentena(5) = "Quinhentos ": aCentena(6) = "Seiscentos "
aCentena(7) = "Setecentos ": aCentena(8) = "Oitocentos "
aCentena(9) = "Novecentos "
'Divide o valor em vrios grupos
cValor = Format$(nValor, "0000000000.00")
aGrupo(1) = Mid$(cValor, 2, 3)
aGrupo(2) = Mid$(cValor, 5, 3)
aGrupo(3) = Mid$(cValor, 8, 3)
aGrupo(4) = "0" + Mid$(cValor, 12, 2)
'Processa cada grupo
For nContador = 1 To 4
cParte = aGrupo(nContador)
nTamanho = Switch(Val(cParte) < 10, 1, Val(cParte) < 100, 2, Val(cParte) < 1000, 3)
If nTamanho = 3 Then
If Right$(cParte, 2) <> "00" Then
aTexto(nContador) = aTexto(nContador) + aCentena(Left(cParte, 1)) + "e "
nTamanho = 2
Else
aTexto(nContador) = aTexto(nContador) + IIf(Left$(cParte, 1) = "1", "Cem ", aCentena(Left(cParte, 1)))
End If
End If
If nTamanho = 2 Then
If Val(Right(cParte, 2)) < 20 Then
aTexto(nContador) = aTexto(nContador) + aUnid(Right(cParte, 2))
Else
aTexto(nContador) = aTexto(nContador) + aDezena(Mid(cParte, 2, 1))
If Right$(cParte, 1) <> "0" Then
aTexto(nContador) = aTexto(nContador) + "e "
nTamanho = 1
End If
End If
End If
If nTamanho = 1 Then
aTexto(nContador) = aTexto(nContador) + aUnid(Right(cParte, 1))
End If
Next
'Gera o formato final do texto
If Val(aGrupo(1) + aGrupo(2) + aGrupo(3)) = 0 And Val(aGrupo(4)) <> 0 Then
cFinal = aTexto(4) + IIf(Val(aGrupo(4)) = 1, "Centavo", "Centavos")
Else
cFinal = ""
cFinal = cFinal + IIf(Val(aGrupo(1)) <> 0, aTexto(1) + IIf(Val(aGrupo(1)) > 1, "Milhes ", "Milho "), "")
If Val(aGrupo(2) + aGrupo(3)) = 0 Then
cFinal = cFinal + "De "
Else
cFinal = cFinal + IIf(Val(aGrupo(2)) <> 0, aTexto(2) + "Mil ", "")
End If
cFinal = cFinal + aTexto(3) + IIf(Val(aGrupo(1) + aGrupo(2) + aGrupo(3)) = 1, "Real", "Reais ")
cFinal = cFinal + IIf(Val(aGrupo(4)) <> 0, "e " + aTexto(4) + IIf(Val(aGrupo(4)) = 1, "Centavo", "Centavos"), "")
End If
Extenso = cFinal
End Function
Dim i As Long
For i = 10007 To 1 Step -1
If Cells(i, "A") = "AVG" Then
Cells(i, "A").EntireRow.Insert
End If
Next i
For i = 10007 To 1 Step -1
If Cells(i, "A") = "AVG - D4" Then
Cells(i, "A").EntireRow.Insert
End If
Next i
For i = 10007 To 1 Step -1
If Cells(i, "A") = "AVG - D3" Then
Cells(i, "A").EntireRow.Insert
End If
Next i
For i = 10007 To 1 Step -1
If Cells(i, "A") = "AVG - D2" Then
Cells(i, "A").EntireRow.Insert
End If
Next i
For i = 10007 To 1 Step -1
If Cells(i, "A") = "AVG - D1" Then
Cells(i, "A").EntireRow.Insert
Exit Sub
End If
Next i
End Sub