![Extracción de texto (letra mayúscula)](https://rvso.com/image/1482495/Extracci%C3%B3n%20de%20texto%20(letra%20may%C3%BAscula).png)
Descargo el historial de transacciones bancarias y me gustaría extraer el nombre de los clientes que se encuentra al final de la línea Descripción. Algunas líneas tienen una o dos palabras antes del nombre del cliente. ¿Cómo puedo extraer los nombres todos en mayúsculas?
También necesito extraer la cantidad transferida del texto y convertirla en números.
DESCRIPTION AMOUNT
TRSF E-BANKING DB 2701/FTSCY/WS95051 12000.00 JAMES BOND 12,000.00 DB
TRSF E-BANKING CR 2701/FTSCY/WS95051 10000.00 deposit CHRISTINE 10,000.00 CR
TRSF E-BANKING CR 2701/FTSCY/WS95051 25025.00 AMANDA B GREEN 25,025.00 CR
TRSF E-BANKING CR 2701/FTSCY/WS95051 5000.00 msn1888 JOSH BROWN 5,000.00 CR
TRSF E-BANKING CR 2701/FTSCY/WS95051 1000.00 topup CHRISTINE 1,000.00 CR
Resultado:
CUSTOMER TRANSFER
JAMES BOND 12,000
CHRISTINE 10,000
AMAND B GREEN 25,025
JOSH BROWN 5,000
CHRISTINE 1,000
TOTAL 53,025
Respuesta1
Usando Macros/VBA:
Public Function extract_name(transaction As String)
Dim WordArray() As String
WordArray() = Split(transaction, " ")
firstName = WordArray(5)
extract_name = firstName
extract_name_uc = UCase(extract_name)
If extract_name = extract_name_uc Then
topBound = 5
Else
topBound = 6
End If
extract_name = ""
For i = topBound To UBound(WordArray)
tempValue = WordArray(i)
If IsNumeric(tempValue) Then
i = UBound(WordArray)
Else
extract_name = extract_name & " " & tempValue
End If
Next i
extract_name = Trim(extract_name)
End Function
Public Function extract_amount(transaction As String)
Dim WordArray() As String
WordArray() = Split(transaction, " ")
extract_amount = WordArray(UBound(WordArray) - 1)
End Function
Hay dos funciones extract_name
y extract_amount
.
Abra VBA con ALT+ F11, inserte un módulo debajoEste libro de trabajoy pega el código en el lado derecho.
Suponiendo que TRSF E-BANKING DB 2701/FTSCY/WS95051 12000.00 JAMES BOND 12,000.00 DB
esté en la celdaA2entonces:
B2 =extract_name(A2)
yC2 =extract_amount(A2)
.