ThiagoAlves025
Membros-
Total de itens
2 -
Registro em
-
Última visita
ThiagoAlves025's Achievements
0
Reputação
-
Olá, a solução para o seu problema pode ser encontrada de uma forma mais fácil via phyton, se o meio para atingir seu objetivo não for problema o Lira da Hashtag treinamento ensina muito bem
-
vania1989 começou a seguir ThiagoAlves025
-
ThiagoAlves025 começou a seguir Alyson Ronnan Martins
-
ThiagoAlves025 começou a seguir VBA
-
encontrar resultado igual ou posterior a uma data
pergunta respondeu ao vania1989 de ThiagoAlves025 em VBA
Olá, segue a solução para o seu problema. qualquer duvida pode mandar DM no insta @thiagoalves.ah, ficarei feliz em ajuda-lo. Sub GetDados() Dim tabDdsMedico As Range Dim tabDdsPaciente As Range Dim iProcesso As String Dim iDate As Date Dim i As Long, j As Long Set tabDdsMedico = Sheet2.Range("A1").CurrentRegion.Offset(1) Set tabDdsPaciente = Sheet1.Range("A1").CurrentRegion.Offset(1) With tabDdsMedico Set tabDdsMedico = .Resize(.Rows.Count - 1) End With With tabDdsPaciente Set tabDdsPaciente = .Resize(.Rows.Count - 1) End With On Error GoTo IfError With tabDdsPaciente For i = 1 To .Rows.Count iProcesso = CStr(.Cells(i, 1)) iDate = CDate(.Cells(i, 2)) For j = 1 To tabDdsMedico.Rows.Count If iProcesso = CStr(tabDdsMedico.Cells(j, 1)) And _ iDate >= CDate(tabDdsMedico.Cells(j, 2)) Then .Cells(i, 3) = tabDdsMedico.Cells(j, 3) .Cells(i, 4) = tabDdsMedico.Cells(j, 4) Exit For End If Next Next End With MsgBox "Processo concluido com sucesso!", vbInformation, "Concluido" Exit Sub IfError: MsgBox "Ocorreu um erro durante o processo de atualização" & _ vbCrLf & "Reveja a macro de atualização", vbCritical End Sub