0% found this document useful (0 votes)
5 views10 pages

Codevol

The document is a VBA macro that creates a new worksheet named 'Evolução' based on the active sheet and populates it with various patient information including identification, age, diagnoses, medical history, and examination results. It retrieves data from specified ranges in the 'L1' sheet and organizes it into a structured format in the new worksheet. The macro includes multiple loops to search for specific keywords and copy corresponding values to the new sheet.

Uploaded by

xy5tkvp4n8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views10 pages

Codevol

The document is a VBA macro that creates a new worksheet named 'Evolução' based on the active sheet and populates it with various patient information including identification, age, diagnoses, medical history, and examination results. It retrieves data from specified ranges in the 'L1' sheet and organizes it into a structured format in the new worksheet. The macro includes multiple loops to search for specific keywords and copy corresponding values to the new sheet.

Uploaded by

xy5tkvp4n8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 10

Sub criar_evolução1()

Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False

Dim wsleito As Worksheet


Dim wsEvolu As Worksheet
Dim ListaLeito As Range
Dim search As Range
Dim LastBlankRow As Integer
Dim Identidade As Range
Dim HMA_Evol As Range
Dim idade As Range

Sheets.Add.Name = "Evolução" & " " & ActiveSheet.Name


Sheets("L1").Activate
Set wsEvolu = Worksheets("Evolução" & " " & ActiveSheet.Name)
'Range("A1").FormulaR1C1 = "Evoluç"

Set wsleito = Worksheets("L1")


Set ListaLeito = wsleito.Range("A1:A500")
Set Identidade = wsleito.Range("B1:F6")
Set HMA_Evol = wsleito.Range("B3:B21")

'Identificação
DataAtual = Worksheets("Original (2)").Range("D5").Value
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "Evolução diurna" & " " & "(" & DataAtual & ")"
.Font.Bold = True
End With

'Nome
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "Nome:"
.Font.Bold = True
End With

For Each search In Identidade


If search.Value = "Nome:" Then
search.Offset(0, 2).Copy wsEvolu.Cells(LastBlankRow, 2)
Exit For
End If

Next search
'Idade
Dim a As Range
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "Idade:"
.Font.Bold = True
End With

For Each search In Identidade


If search.Value = "Idade:" Then
wsEvolu.Cells(LastBlankRow, 2).Value = search.Offset(0, 1).Value
Exit For
End If
Next search

'Diagnosticos
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "#Diagnósticos"
.Font.Bold = True
End With

For Each search In ListaLeito


If search.Value = "Diagnóstico(s):" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
search.Offset(0, 1).Copy wsEvolu.Cells(LastBlankRow, 1)
End If
Next search

'HMA
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "#História da moléstia atual:"
.Font.Bold = True
End With

For Each search In HMA_Evol


If search.Value = "# HMA" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
search.Offset(1, 0).Copy wsEvolu.Cells(LastBlankRow, 1)
Exit For
End If
Next search

'Antecedentes
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "Antecedentes:"
.Font.Bold = True
End With

For Each search In ListaLeito:


If search.Value = "Antecedentes:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
search.Offset(0, 1).Copy wsEvolu.Cells(LastBlankRow, 1)
End If
Next search

'Labs externos
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "#Exames laboratoriais alterados (realizados em outro serviço):"
.Font.Bold = True
End With

For Each search In HMA_Evol


If search.Value = "#Labs(outro serviço):" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
search.Offset(1, 0).Copy wsEvolu.Cells(LastBlankRow, 1)
Exit For
End If
Next search

'Imagens externos
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "#Exames de imagem (realizados em outro serviço):"
.Font.Bold = True
End With

For Each search In HMA_Evol


If search.Value = "#Imagens (Outro serviço):" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
search.Offset(1, 0).Copy wsEvolu.Cells(LastBlankRow, 1)
Exit For
End If
Next search

'Evolução
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "#Evolução"
.Font.Bold = True
End With

For Each search In HMA_Evol


If search.Value = "# Evolução:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
search.Offset(1, 0).Copy wsEvolu.Cells(LastBlankRow, 1)
Exit For
End If
Next search

'Controles
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "#Controles:"
.Font.Bold = True
End With

For Each search In ListaLeito:


If search.Value = "PAM/24horas" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = " PAM/24horas: " & " " &
"mínima:" _
& search.Offset(0, 2).Value & " máxima: " & search.Offset(0, 4).Value
Exit For
End If
Next search

For Each search In ListaLeito:


If search.Value = "FC/24horas:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = " FC/24horas: " & " " &
"mínima:" _
& search.Offset(0, 2).Value & " máxima: " & search.Offset(0, 4).Value
Exit For
End If
Next search

For Each search In ListaLeito:


If search.Value = "FR/24 horas:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = " FR/24horas: " & " " &
"mínima:" _
& search.Offset(0, 2).Value & " máxima: " & search.Offset(0, 4).Value
Exit For
End If
Next search

For Each search In ListaLeito:


If search.Value = "FR/24 horas:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = " SatO2/24horas: " & " " &
"mínima:" _
& search.Offset(0, 2).Value & " máxima: " & search.Offset(0, 4).Value
Exit For
End If
Next search

'Exame Fisico:
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "#Exame Fisíco:"
.Font.Bold = True
End With

For Each search In ListaLeito:


If search.Value = "Exame Físico(N):" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = "Neurológico:" & " " &
search.Offset(0, 1).Value
Exit For
End If
Next search

For Each search In ListaLeito:


If search.Value = "Exame Físico(CV):" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = "Aparelho cardiovascular:" & " "
& search.Offset(0, 1).Value
Exit For
End If
Next search

For Each search In ListaLeito:


If search.Value = "Exame Físico(R):" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = "Aparelho Respiratório:" & " " &
search.Offset(0, 1).Value
Exit For
End If
Next search

For Each search In ListaLeito:


If search.Value = "Exame Físico(Abd):" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = "Aparelho digestivo:" & " " &
search.Offset(0, 1).Value
Exit For
End If
Next search

For Each search In ListaLeito:


If search.Value = "Exame Físico(ext):" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = "Exame dos membros
inferiores e superiores:" & " " & search.Offset(0, 1).Value
Exit For
End If
Next search

For Each search In ListaLeito:


If search.Value = "Exame Físico(peleeA):" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = "Pele e anexos:" & " " &
search.Offset(0, 1).Value
Exit For
End If
Next search

'Sedação
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "#Sedação:"
.Font.Bold = True
End With

For Each search In ListaLeito:


If search.Value = "Sedação:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = search.Offset(0, 1).Value &
search.Offset(0, 2).Value
Exit For
End If
Next search

'DVA
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "# Drogas inotrópicas e vasopressoras:"
.Font.Bold = True
End With

For Each search In ListaLeito:


If search.Value = "Drogas Ino./Vaso." Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = search.Offset(0, 1).Value &
search.Offset(0, 2).Value _
& " " & search.Offset(0, 3).Value & " " & search.Offset(0, 4).Value & " " &
search.Offset(0, 5).Value _
& " " & search.Offset(0, 6).Value & " " & search.Offset(0, 7).Value & " " &
search.Offset(0, 8).Value _
& " " & search.Offset(0, 9).Value & " " & search.Offset(0, 10).Value & " "
& search.Offset(0, 11).Value
Exit For
End If
Next search

'Dispositivos:
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "#Dispositivos:"
.Font.Bold = True
End With

For Each search In ListaLeito:


If search.Value = "Dispositivos:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = search.Offset(0, 1).Value &
search.Offset(0, 2).Value
Exit For
End If
Next search

'Parâmetros Ventilatórios:
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "# Parâmetros Ventilatórios:"
.Font.Bold = True
End With

For Each search In ListaLeito:


If search.Value = "Ventilação:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = search.Offset(0, 1).Value &
search.Offset(0, 2).Value _
& " " & search.Offset(0, 3).Value & " " & search.Offset(0, 4).Value & " " &
search.Offset(0, 5).Value _
& " " & search.Offset(0, 6).Value & " " & search.Offset(0, 7).Value & " " &
search.Offset(0, 8).Value _
& " " & search.Offset(0, 9).Value & " " & search.Offset(0, 10).Value & " "
& search.Offset(0, 11).Value _
& " " & search.Offset(0, 12).Value & " " & search.Offset(0, 13).Value
Exit For
End If
Next search

'Nutrição:
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "#Dispositivos:"
.Font.Bold = True
End With

For Each search In ListaLeito:


If search.Value = "Nutrição" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = search.Offset(0, 1).Value
Exit For
End If
Next search

'Renal:
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "#Renal:"
.Font.Bold = True
End With

For Each search In ListaLeito:


If search.Value = "Debito urinário:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = "Debito urinário: " &
search.Offset(0, 1).Value & search.Offset(0, 2).Value _
& " " & search.Offset(0, 3).Value & " " & search.Offset(0, 4).Value & " " &
search.Offset(0, 5).Value _
& " " & search.Offset(0, 6).Value & " " & search.Offset(0, 7).Value
Exit For
End If
Next search

For Each search In ListaLeito:


If search.Value = "Balanço hídrico:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = "Balanço hídrico:" &
search.Offset(0, 1).Value & search.Offset(0, 2).Value _
& " " & search.Offset(0, 3).Value & " " & search.Offset(0, 4).Value & " " &
search.Offset(0, 5).Value _
& " " & search.Offset(0, 6).Value & " " & search.Offset(0, 7).Value
Exit For
End If
Next search

For Each search In ListaLeito:


If search.Value = "Função Renal:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = "Função Renal:" &
search.Offset(0, 1).Value
Exit For
End If
Next search

For Each search In ListaLeito:


If search.Value = "Eletrólitos:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = "Eletrólitos:" & search.Offset(0,
1).Value
Exit For
End If
Next search

'Hematológico e Infeccioso:
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "#Hematológico e Infeccioso:"
.Font.Bold = True
End With

For Each search In ListaLeito:


If search.Value = "Temp./24horas" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = "Temperatura/24horas: " & " " &
"mínima:" _
& search.Offset(0, 2).Value & " máxima: " & search.Offset(0, 4).Value
Exit For
End If
Next search

For Each search In ListaLeito:


If search.Value = "Hemograma:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = "Hemograma: " &
search.Offset(0, 1).Value
Exit For
End If
Next search

LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1


With wsEvolu.Cells(LastBlankRow, 1)
.Value = "Culturas:"
End With

For Each search In ListaLeito:


If search.Value = "Culturas:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = search.Offset(0, 1).Value
Exit For
End If
Next search

For Each search In ListaLeito:


If search.Value = "ATB:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
wsEvolu.Cells(LastBlankRow, 1).Value = "Antibióticos:" &
search.Offset(0, 1).Value
Exit For
End If
Next search

'Antecedentes
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
With wsEvolu.Cells(LastBlankRow, 1)
.Value = "#Conduta médica::"
.Font.Bold = True
End With

For Each search In ListaLeito:


If search.Value = "Conduta:" Then
LastBlankRow = wsEvolu.Cells(Rows.Count, 1).End(xlUp).Row + 1
search.Offset(0, 1).Copy wsEvolu.Cells(LastBlankRow, 1)
End If
Next search

Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
End Sub

You might also like