Vídeo recomendado
https://youtu.be/diWPPPhW-9E
https://youtu.be/diWPPPhW-9E
Macro para exibir MsgBox de Vencimento
- Mikel Silveira Fraga
- Jedi
- Mensagens: 1173
- Registrado em: Sex Mai 27, 2011 3:27 pm
- Localização: Governador Valadares - MG
- Contato:
Re: Macro para exibir MsgBox de Vencimento
ImIperes, boa noite e seja bem vindo ao fórum.
Então, esse código simula a execução do comando Ctrl + Seta para Cima, retornando o número da última linha preenchia, enviando para uma variável ou um controle ActiveX.
Por exemplo, suponhamos que na coluna E, exista informações preenchidas até a linha 1450. Então, esse comando irá retornar o número da linha 1450. Esse comando também pode ser usado como um limite superior de um laço For, por exemplo.
Se tiver um exemplo para testar, a explicação fica melhor.
Abraços e boa noite.
Então, esse código simula a execução do comando Ctrl + Seta para Cima, retornando o número da última linha preenchia, enviando para uma variável ou um controle ActiveX.
Por exemplo, suponhamos que na coluna E, exista informações preenchidas até a linha 1450. Então, esse comando irá retornar o número da linha 1450. Esse comando também pode ser usado como um limite superior de um laço For, por exemplo.
Se tiver um exemplo para testar, a explicação fica melhor.
Abraços e boa noite.
Re: Macro para exibir MsgBox de Vencimento
Boa noite amigos, conforme os códigos abaixo citados:
Como faço para fazer esse mesmo procedimento em meu projeto, ele esta com banco de dados no access...
segue anexo.
aguardo ajuda amigos.
Sub LocalizaPrimeiroVencido()
Dim I As Variant
Dim wshVenc As Worksheet
Set wshVenc = Worksheets("BASE") 'Altere para o nome da sua Aba
For Each I In wshVenc.Range("E2:E" & wshVenc.Range("A65536").End(xlUp).Row)
If I = "Menos de Cinco Dias" Then
MsgBox "existem datas,com menos de cinco dias para o vencimento"
Exit Sub
End If
Next
Private Sub Workbook_Open()
Call LocalizaPrimeiroVencido
End Sub
Como faço para fazer esse mesmo procedimento em meu projeto, ele esta com banco de dados no access...
segue anexo.
aguardo ajuda amigos.
Sub LocalizaPrimeiroVencido()
Dim I As Variant
Dim wshVenc As Worksheet
Set wshVenc = Worksheets("BASE") 'Altere para o nome da sua Aba
For Each I In wshVenc.Range("E2:E" & wshVenc.Range("A65536").End(xlUp).Row)
If I = "Menos de Cinco Dias" Then
MsgBox "existem datas,com menos de cinco dias para o vencimento"
Exit Sub
End If
Next
Private Sub Workbook_Open()
Call LocalizaPrimeiroVencido
End Sub
- Anexos
-
- CONTROLE DE FROTA.rar
- (153.03 KiB) Baixado 245 vezes
Alinhar à Direita
Boa noite amigos, eu queria ajuda de vocês, estou tentando que o valor exportado fique alinhado a direita na célula do Excel, mas não consegui. Segue código abaixo:
Private Sub cmd_exportar_Click()
On Error Resume Next
Application.ScreenUpdating = False
Dim i, j As Integer
Dim Item As ListItem
Dim Linha As Integer
Linha = 2
cmd_salvar.Locked = True
Sheets("Relatorios").Select
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Clear
Range("A1:G1").Value = Array("OS", "DATA", "CLIENTES", "CNPJ/CPF", "PLACA", "TELEFONE", "TOTAL R$")
Range("A1:G1").Select
Selection.Font.Bold = True
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -4.99893185216834E-02
.PatternTintAndShade = 0
End With
'Loop as lignes
For i = 1 To ListView1.ListItems.Count
'Loop as colunas
For j = 1 To 1
Plan2.Cells(i + 1, 1) = ListView1.ListItems(i).ListSubItems(1).Text
Plan2.Cells(i + 1, 2) = CDate(ListView1.ListItems(i).ListSubItems(2))
Plan2.Cells(i + 1, 3) = ListView1.ListItems(i).ListSubItems(3).Text
Plan2.Cells(i + 1, 4) = ListView1.ListItems(i).ListSubItems(4).Text
Plan2.Cells(i + 1, 5) = ListView1.ListItems(i).ListSubItems(5).Text
Plan2.Cells(i + 1, 6) = ListView1.ListItems(i).ListSubItems(6).Text
Plan2.Cells(i + 1, 7) = Format(ListView1.ListItems(i).ListSubItems(7), "0.00")
Linha = Linha + 1
Sheets("RELATORIOS").Cells(Linha, 1) = ""
Sheets("RELATORIOS").Cells(Linha, 2) = ""
Sheets("RELATORIOS").Cells(Linha, 3) = ""
Sheets("RELATORIOS").Cells(Linha, 4) = ""
Sheets("RELATORIOS").Cells(Linha, 5) = ""
Sheets("RELATORIOS").Cells(Linha, 6) = ""
Sheets("RELATORIOS").Cells(Linha, 7) = Format(RELATORIOS_SISTEMA.lb_total, "0.00")
Next j
Next i
Range("A1").Select
Selection.CurrentRegion.Select
With Selection.Font
.Name = "Thaoma"
.Size = 8
End With
Call Bordas
Columns("A:G").EntireColumn.AutoFit
Sheets("Principal").Select
Application.ScreenUpdating = True
MsgBox "RELATÓRIO GERADO COM SUCESSO!", 0 + vbInformation, "RELATÓRIO"
Plan2.Activate
Application.Visible = True
Unload Me
MENU_PRINCIPAL.Hide
Application.Dialogs(xlDialogPrintPreview).Show
Application.Visible = False
Plan1.Activate
MENU_PRINCIPAL.Show
Private Sub cmd_exportar_Click()
On Error Resume Next
Application.ScreenUpdating = False
Dim i, j As Integer
Dim Item As ListItem
Dim Linha As Integer
Linha = 2
cmd_salvar.Locked = True
Sheets("Relatorios").Select
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Clear
Range("A1:G1").Value = Array("OS", "DATA", "CLIENTES", "CNPJ/CPF", "PLACA", "TELEFONE", "TOTAL R$")
Range("A1:G1").Select
Selection.Font.Bold = True
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -4.99893185216834E-02
.PatternTintAndShade = 0
End With
'Loop as lignes
For i = 1 To ListView1.ListItems.Count
'Loop as colunas
For j = 1 To 1
Plan2.Cells(i + 1, 1) = ListView1.ListItems(i).ListSubItems(1).Text
Plan2.Cells(i + 1, 2) = CDate(ListView1.ListItems(i).ListSubItems(2))
Plan2.Cells(i + 1, 3) = ListView1.ListItems(i).ListSubItems(3).Text
Plan2.Cells(i + 1, 4) = ListView1.ListItems(i).ListSubItems(4).Text
Plan2.Cells(i + 1, 5) = ListView1.ListItems(i).ListSubItems(5).Text
Plan2.Cells(i + 1, 6) = ListView1.ListItems(i).ListSubItems(6).Text
Plan2.Cells(i + 1, 7) = Format(ListView1.ListItems(i).ListSubItems(7), "0.00")
Linha = Linha + 1
Sheets("RELATORIOS").Cells(Linha, 1) = ""
Sheets("RELATORIOS").Cells(Linha, 2) = ""
Sheets("RELATORIOS").Cells(Linha, 3) = ""
Sheets("RELATORIOS").Cells(Linha, 4) = ""
Sheets("RELATORIOS").Cells(Linha, 5) = ""
Sheets("RELATORIOS").Cells(Linha, 6) = ""
Sheets("RELATORIOS").Cells(Linha, 7) = Format(RELATORIOS_SISTEMA.lb_total, "0.00")
Next j
Next i
Range("A1").Select
Selection.CurrentRegion.Select
With Selection.Font
.Name = "Thaoma"
.Size = 8
End With
Call Bordas
Columns("A:G").EntireColumn.AutoFit
Sheets("Principal").Select
Application.ScreenUpdating = True
MsgBox "RELATÓRIO GERADO COM SUCESSO!", 0 + vbInformation, "RELATÓRIO"
Plan2.Activate
Application.Visible = True
Unload Me
MENU_PRINCIPAL.Hide
Application.Dialogs(xlDialogPrintPreview).Show
Application.Visible = False
Plan1.Activate
MENU_PRINCIPAL.Show
Implimir Listview
Olá amigos, gostaria da ajuda de vocês para este código em anexo, estou tentando imprimir mas ele da um erro... Alguém pode me ajudar?
- Anexos
-
- imprimir listview.rar
- (23.35 KiB) Baixado 232 vezes
- Reinaldo
- Jedi
- Mensagens: 1537
- Registrado em: Sex Ago 01, 2014 4:09 pm
- Localização: Garça - SP / SCS - SP
Re: Macro para exibir MsgBox de Vencimento
Creio que a rotina obtida está incompleta.
o que é presuposto "Printer" executar ("...Width * Printer.")
P.S.: Está pegando carona em um topico antigo que se refere a outra(s) demanda(s); o ideal seria abrir seu próprio tópico, referenciando se necessário o tópico base/inicial
o que é presuposto "Printer" executar ("...Width * Printer.")
P.S.: Está pegando carona em um topico antigo que se refere a outra(s) demanda(s); o ideal seria abrir seu próprio tópico, referenciando se necessário o tópico base/inicial