Ir para conteúdo
Fórum Script Brasil
  • 0

EXCEL INVERTE DIA E MES EM UMA LISTBOX NO VBA


wvico

Pergunta

Boa tarde a todos estou com mesmo problema em uma planilha que estou montando de controle de medicação
quando realizo o filtro entre datas ele aparece certo mas quando transfiro para a planilha ela inverte o dia e mês. já li todos os post referentes a minha duvida mas não consigo soluciona-la :
Segue os códigos que estou usando:
Este é para carregar a listbox:
Private Sub cmd_pesquisar_Click()
Dim LINHAFINAL, linha, X As Integer


ListBox1.Clear
LINHAFINAL = Plan2.Cells(Rows.Count, 1).End(xlUp).Row

X = 0
For linha = 4 To LINHAFINAL
If Plan2.Cells(linha, 2).Value >= Month_data_inicial And Plan2.Cells(linha, 2).Value <= Month_data_final Then
ListBox1.AddItem Plan2.Cells(linha, 3).Value (esta variável é um data)
ListBox1.List(X, 1) = Plan2.Cells(linha, 4).Value (esta variável é um data)
ListBox1.List(X, 2) = Plan2.Cells(linha, 5).Value
ListBox1.List(X, 3) = Plan2.Cells(linha, 6).Value
ListBox1.List(X, 4) = Plan2.Cells(linha, 7).Value
ListBox1.List(X, 5) = Plan2.Cells(linha, 8).Value
ListBox1.List(X, 6) = Plan2.Cells(linha, 9).Value
ListBox1.List(X, 7) = Plan2.Cells(linha, 10).Value

X = X + 1
End If
Next
End Sub

e este é para limpar e formatar os dados da minha planilha e depois gravar o dados da listbox
Private Sub UserForm_Initialize()




Sheets("RELATÓRIO").Select
Range("A3").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Y = ActiveCell.Row
Rows(Y).Select
Selection.Delete Shift:=xlUp
Range("A3").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone


Dim LINHAFINAL, linha, X As Integer
Sheets("RELATÓRIO").Select



ListBox1.Clear
LINHAFINAL = Plan2.Cells(Rows.Count, 1).End(xlUp).Row

X = 0
For linha = 4 To LINHAFINAL
ListBox1.AddItem Plan2.Cells(linha, 3).Value (esta variável é um data)
ListBox1.List(X, 1) = Plan2.Cells(linha, 4).Value (esta variável é um data)
ListBox1.List(X, 2) = Plan2.Cells(linha, 5).Value
ListBox1.List(X, 3) = Plan2.Cells(linha, 6).Value
ListBox1.List(X, 4) = Plan2.Cells(linha, 7).Value
ListBox1.List(X, 5) = Plan2.Cells(linha, 8).Value
ListBox1.List(X, 6) = Plan2.Cells(linha, 9).Value
ListBox1.List(X, 7) = Plan2.Cells(linha, 10).Value


X = X + 1
Next

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,8k
×
×
  • Criar Novo...