Adicionado em: | 31/03/2013 |
Modificado em: | 31/03/2013 |
Tamanho: | Vazio |
Downloads: | 3407 |
Escola Saberexcel VBA Estudos® - Treinamentos com Macros, Fórmulas e Funções
Esses procedimentos do Aplicativo Microsoft Excel VBA(visual Basic Application), com auxilio de um objeto ListView busca dados baseados
em determinados critérios e retorna também a soma dos valores Filtrados no objeto ListView, contém folha de planilha para o relatório de
dados filtrados.
Option Explicit
Dim TabelaTemp As Variant
Dim vUltimaLinha As Integer
Dim L As Integer
Dim X As Integer
Dim I As Integer
Dim C As Byte
Dim vLin As Integer
Dim TotalCol As Single
Private Sub CheckBox1_Click()
If frmLANCAMENTOS.CheckBox1.Value = True Then Call AdicionaItem
End Sub
Private Sub cbxAGENCIA_Change()
If frmLANCAMENTOS.CheckBox1.Value = True Then
Call AdicionaItem
Exit Sub
End If
If frmLANCAMENTOS.cbxAGENCIA.Value = "" Then Exit Sub
' verifica a combobox lista meses
frmLANCAMENTOS.cbxMESES.Value = ""
' & Se desmarcada, construído de acordo com a agência lista
With Me.ListView1
.ListItems.Clear
With .ColumnHeaders
.Clear
.Add , , "Data", 50
.Add , , "Agencia", 70
.Add , , "Cliente", 95
.Add , , "Total", 50
End With
.FullRowSelect = True
.Gridlines = True
.LabelEdit = 1
.ListItems.Clear
.View = lvwReport
With ThisWorkbook.Worksheets("BD")
.Activate
vUltimaLinha = .Range("A65535").End(xlUp).Row
TabelaTemp = .Range(.Cells(2, 1), .Cells(vUltimaLinha, 4)).Value
.Range("A1").Sort Key1:=.Range("A2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
X = 1
TotalCol = 0
For L = 1 To UBound(TabelaTemp, 1)
If TabelaTemp(L, 2) = Me.cbxAGENCIA.Value Then
.ListItems.Add , , TabelaTemp(L, 1)
.ListItems(X).ListSubItems.Add , , TabelaTemp(L, 2)
.ListItems(X).ListSubItems.Add , , TabelaTemp(L, 3)
.ListItems(X).ListSubItems.Add , , TabelaTemp(L, 4)
TotalCol = TotalCol + TabelaTemp(L, 4)
X = X + 1
End If
Next
End With
'TOTAL
Me.TotListView.Value = TotalCol
With Me.txtTotal
Me.txtTotal = ListView1.ListItems.Count - 0
End With
End Sub
Private Sub cbxMESES_Change()
If frmLANCAMENTOS.CheckBox1.Value = True Then
Call AdicionaItem
Exit Sub
End If
If frmLANCAMENTOS.cbxMESES.Value = "" Then Exit Sub
frmLANCAMENTOS.cbxAGENCIA.Value = ""
' Se desmarcada, construído a lista por MÊS
With Me.ListView1
.ListItems.Clear
With .ColumnHeaders
.Clear
.Add , , "Data", 50
.Add , , "Agencia", 70
.Add , , "Cliente", 95
.Add , , "Total", 50
End With
.FullRowSelect = True
.Gridlines = True
.LabelEdit = 1
.ListItems.Clear
.View = lvwReport
With ThisWorkbook.Worksheets("BD")
.Activate
vUltimaLinha = .Range("A65535").End(xlUp).Row
TabelaTemp = .Range(.Cells(2, 1), .Cells(vUltimaLinha, 4)).Value
.Range("A1").Sort Key1:=.Range("A2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
X = 1
TotalCol = 0
For L = 1 To UBound(TabelaTemp, 1)
If Format(CDate(TabelaTemp(L, 1)), "mmmm") = Me.cbxMESES.Value Then
.ListItems.Add , , TabelaTemp(L, 1)
.ListItems(X).ListSubItems.Add , , TabelaTemp(L, 2)
.ListItems(X).ListSubItems.Add , , TabelaTemp(L, 3)
.ListItems(X).ListSubItems.Add , , TabelaTemp(L, 4)
TotalCol = TotalCol + TabelaTemp(L, 4)
X = X + 1
End If
Next L
End With
Me.TotListView.Value = TotalCol
'TOTAL
With Me.txtTotal
Me.txtTotal = ListView1.ListItems.Count - 0
End With
End Sub
Sub AdicionaItem()
With Me.ListView1
.ListItems.Clear
With .ColumnHeaders
.Clear
.Add , , "Data", 50
.Add , , "Agencia", 70
.Add , , "Cliente", 95
.Add , , "Total", 50
End With
.FullRowSelect = True
.Gridlines = True
.LabelEdit = 1
.ListItems.Clear
.View = lvwReport
With ThisWorkbook.Worksheets("BD")
.Activate
vUltimaLinha = .Range("A65535").End(xlUp).Row
TabelaTemp = .Range(.Cells(2, 1), .Cells(vUltimaLinha, 4)).Value
.Range("A1").Sort Key1:=.Range("A2"), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
X = 1
TotalCol = 0
For L = 1 To UBound(TabelaTemp, 1)
If TabelaTemp(L, 2) = Me.cbxAGENCIA.Value Then
If Format(CDate(TabelaTemp(L, 1)), "mmmm") = Me.cbxMESES.Value Then
.ListItems.Add , , TabelaTemp(L, 1)
.ListItems(X).ListSubItems.Add , , TabelaTemp(L, 2)
.ListItems(X).ListSubItems.Add , , TabelaTemp(L, 3)
.ListItems(X).ListSubItems.Add , , TabelaTemp(L, 4)
TotalCol = TotalCol + TabelaTemp(L, 4)
X = X + 1
End If
End If
Next L
End With
'TOTAL
Me.TotListView.Value = TotalCol
With Me.txtTotal
Me.txtTotal = ListView1.ListItems.Count - 0
End With
End Sub
Private Sub cmdFECHAR_Click()
Unload Me
End Sub
Private Sub UserForm_initialize()
cbxAGENCIA.RowSource = "Lista!A2: A10"
cbxMESES.RowSource = "Lista!B2: B13"
End Sub
'IMPRESSAO
Private Sub cmdImprimer_Click()
vLin = 1
With Me.ListView1
For I = 1 To .ListItems.Count
vLin = vLin + 1
Sheets("Impressao").Cells(vLin, 1) = .ListItems(I)
Sheets("Impressao").Cells(vLin, 2) = .ListItems(I).ListSubItems(1)
Sheets("Impressao").Cells(vLin, 3) = .ListItems(I).ListSubItems(2)
Sheets("Impressao").Cells(vLin, 4) = .ListItems(I).ListSubItems(3)
Next I
End With
MsgBox "dados imprimidos com sucesso folha impressao", vbInformation, "Escola Saberexcel VBA Estudos®"
'sbx_impressao
'sbx_limpar_Impressao
End Sub
Aprenda tudo sobre planilhas do Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Escola Saberexcel VBA Estudos® - Treinamentos com Macros, Fórmulas e Funções.
.
Adicionado em: | 29/03/2011 |
Modificado em: | 29/03/2011 |
Tamanho: | Vazio |
Downloads: | 3641 |
Esse procedimento do Aplicativo Microsoft Excel VBA(Visual Basic Application), retorna o resultado da multiplicação entre dois objetos, duas textbox(caixa de texto), e formata os textbox como Moeda, neste caso Reais.
Espero que o exemplo lhe seja útil. Fique com Deus, Boas Pesquisas.
'esse procedimento retorna o resultado da multiplicação entre dois textbox,
'TextBox1 x TextBox2, retorna em :
'Retorna valor com centavos em uma Label,
'Retorna valor com centavos em um Frame,
'Retorna no caption do Userform1
'Retorna Também na Célula(B16) o valor da multiplicação
'Ao Fechar o userform (QueryClose) limpa a célula (B16)
Private Sub TextBox2_Change()
vNum1 = TextBox1.Value
vNum2 = TextBox2.Value
Label1.Caption = "Resultado da Multiplicação: [ " & Format(vNum1 * vNum2, "R$ ###,###.00") & " ]"
Frame1.Caption = "Resultado : TextBox1 x TextBox2 = [ " & Format(vNum1 * vNum2, "R$ ###,###.00") & " ]"
UserForm1.Caption = "Resultado : TextBox1 x TextBox2 = [ " & Format(vNum1 * vNum2, "R$ ###,###.00") & " ]"
[B16].Value = "Resultado : TextBox1 x TextBox2 = [ " & Format(vNum1 * vNum2, "R$ ###,###.00") & " ]"
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
[B16].Value = ""
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Aprenda tudo sobre o Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos SaberExcel
Publicidade
Compre com segurança, garantia e ótimos preços
Adicionado em: | 29/11/2010 |
Modificado em: | 29/11/2010 |
Tamanho: | Vazio |
Downloads: | 5343 |
Saberexcel - o site das macros
Exemplos de planilha do Aplicativo Microsoft Excel VBA, contendo userforms e textboxes, com simplicidade de contas a pagar, porém pode ser muito bem aproveitado, a intenção é ensinar um caminho para se fazer, uma boa formatação e usar alguns macros em exemplos de planilha.
Abaixo a imagem do formulário gerado pela planilha exemplo. Neste exemplo voce poderá ver como ligar um determinado textbox à uma célula, para mostrar um determinado valor.
Aprenda Microsoft Excel VBA - SaberExcel
Adicionado em: | 01/05/2011 |
Modificado em: | 01/05/2011 |
Tamanho: | Vazio |
Downloads: | 6215 |
Saberexcel - o site de quem precisa Aprender Macros MS Excel VBA
Esses procedimentos do Aplicativo Microsoft Excel VBA(Visual Basic Application), usando objetos checkboxes, através de um commandbutton no objeto userform, insere uma seleção em todos os checkboxes existentes, como também retira essa seleção. Observe que também voce poderá mudar a cor do frame, botão, userform, como também as fontes...
'Private Sub CommandButton1_Click()
' CheckBox1 = True
' CheckBox2 = True
' CheckBox3 = True
' CheckBox4 = True
' CheckBox5 = True
' CheckBox6 = True
' CheckBox7 = True
' CheckBox8 = True
' CheckBox9 = True
' CheckBox10 = True
'End Sub
'Prezado Silvio, o jeito que você estava fazendo também funciona, porém para fazermos isso em um só botão, fica melhor se fizermos da seguinte forma, usando um Loop For ... Next. Acredito que fica melhor, veja. Espero que o exemplo possa ajudá-lo Fique com Deus. Expedito Marcondes.
Private Sub CommandButton1_Click()
For i = 1 To 10
Controls("CheckBox" & i) = Not Controls("CheckBox" & i)
Next
'condição if somente para inserir no frame se os chekbox estão ou nao selecionados.
If CheckBox1 = True Then
Me.Frame1.Caption = "Checkboxes ATIVADOS!!"
Me.Frame1.BackColor = &HC0FFFF
Else
Me.Frame1.Caption = "Checkboxes Desativados!"
Me.Frame1.BackColor = &HFFFFC0
End If
End Sub
Aprenda tudo sobre planilhas do Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Saberexcel
Publicidade
Compre com segurança, garantia e ótimos preços
Adquira já o Acesso Imediato
à Area de Membros
Aprenda Excel VBA com Simplicidade de
códigos e Eficácia, Escrevendo Menos e
Fazendo Mais.
'-------------------------------------'
Entrega Imediata:
+ 500 Video Aulas MS Excel VBA
+ 35.000 Planilhas Excel e VBA
+ Coleção 25.000 Macros MS Excel VBA
+ 141 Planilhas Instruções Loops
+ 341 Planilhas WorksheetFunctions(VBA)
+ 04 Módulos Como Fazer Excel VBA
+ Curso Completo MS Excel VBA
+ Planilhas Inteligentes
<script type="text/javascript"><!--
google_ad_client = "ca-pub-2317234650173689";
/* retangulo 336 x 280 */
google_ad_slot = "0315083363";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
Aprenda tudo sobre o Aplicativo Microsoft Excel VBA(Visual Basic Application), sozinho, com baixo custo, praticando com os produtos didáticos Saberexcel,
Sobre as WorksheetFunctions Funções de Planilhas que retornam valores do VBA