Loop Through Multiple Columns, Match Against Criteria and Paste Cell in Blank Workbook...

juanbolas

New Member
Joined
Dec 3, 2014
Messages
40
Office Version
  1. 365
Platform
  1. Windows
Hello

I'm trying to process a bunch for pdf documents (that are not actual forms). I need to get data from specific fields which are all over the place inti a blank sheet. i loop through the rows of the data, then the columns and finally i loop against the criteria and do a like to match. But something is not right and I am missing data and getting repeated data in the blank sheet.

the data is from the messy converted sheet

parse MIRC-DTA4.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAG
1Manifiesto Internacional de Carga por Carretera / Declaracion de Transito Aduanero MIC/DTA Manifiesto Internacional de Carga Rodoviaria / Declarac?o de Transito Aduaneiro
21 Nombre y domicilio del porteador / Nome e endereco do transportador Nombre Dirección Ciudad3 Transito aduanero Transito aduaneiro X Si No Sim N?o4 N? Aasdsdasx
35 Hoja / Folha 1 / 16 Fecha Emision / Data de emissao 24-ENE-22
47 Aduana, ciudad y pais de partida / Alfandega, cidade e pais de partida BS.AS.(CAPITAL)-ARGENTINA
5Lugar Operativo22321123332
62 Rol de contribuyente / Cadastro geral de contribuintes 3079999999)
7544
89 CAMION ORIGINAL : Nombre y domicilio del propietario CAMINH?O ORIGINAL : Nome e endereco do proprietario Nombre 2 Dirección 2 Teléfono 216 CAMION SUBSTITUTO : Nombre y domicilio del propietario CAMINH?O SUBSTITUTO : Nome e endereco do proprietario
910 Rol de Contribuyente Cadastro geral de contribuintes 39999999999911 Placa de Camion Placa do caminh?Axxxxx17 Rol de Contribuyente Cadastro geral de contribuintes18 Placa de Camion Placa do caminhao
1012 Marca y numero / Marca e numero VOLVO 13 Capacidad de arrastre (t.) Capacidade de tracao (t.) 4519 Marca y numero / Marca e numero20 Capacidad de arrastre (t.) Capacidade de tracao (t.)
1114 A?o / Ano 200815Semiremolque Semi-reboqueRemolque Reboque21 A?o / Ano22Semiremolque Semi-reboqueRemolque Reboque
12Placa: sx000000Placa:
1323 N? carta de porte N? de conhecimiento 001UY000924 Aduana de destino/ Alfandega de destino FRAY BENTOS-33 Remitente / Remetente NOMBRE REMITENTE Direccion rem ciudad rem
14006
1525 Moneda/ Moeda DOL26 Origen de las mercancia / Origem das mercadorias ARGENTINA34 Destinatario / Destinatario Nombre destino Dir destino ciudad destino
16200
1727 Valor FOT /Valor FOT 129828 Flete en U$S Frete em U$S 2000.0029 Seguro en U$S Seguro en U$S .0035 Consignatario /Consignatario Nombre Consig Dir Consig
1830 Tipo de Bultos Tipo dos volumes BULTOS PALETA31 Cantidad de bultos Quantidade de volumes 2632 Peso bruto (kg.) Peso bruto (kg.) 4112.2436 Documentos Anexos /Documentos anexos Destinacion: asasaxzxzxzzx
1903
2037 Numero de los precintos /Numero dos lacres MSADO6 - MSADO2
2138 Marcas y numeros de los bultos, descripcion de las mercancias / Marcas e numeros dos volumes, descric?o das mercadorias SON 26 PALLETS QUE DICEN CONTENER: MEDICAMENTOS - MANTENER TEMPERATURA ENTRE 15C Y 25C.
22
23Declaramos que las informaciones presentadas en este Documento son expresion de verdad, que los datos referentes a las mercancias fueron transcriptos exactamente conforme a la declaracion del remitente, los cuales son de su exclusiva responsabilidad, y que esta operacion obedece a lo dispuesto en el Convenio sobre Transporte Internacional Terrestre de los paises del Cono Sur. Declaramos que as informacoes prestadas neste Documento s?o a express?o da verdade, que os dados referentes as mercadorias foram transcritos exatamente conforme a declarac?o do remetente, os quais s?o de su exclusiva responsabilidade, e que esta operacao obedece ao disposto no Convenio sobre Transporte Internacional Terrestre dos Paises do Cone Sul. 39 Firma y sello del porteador/Assinatura e carimbo do transportador Fecha /Data40 N? DTA, ruta y plazo de transporte /N? DTA, rota e prazo de transporte RUTA A SEGUIR
2441 Firma y sello de Aduana de Partida /Assinatura e carimbo de Alfandega de Partida Fecha /Data
Copy



The criteria range are the titles of some of the form's fileds. And it's a dynamic named range:

parse MIRC-DTA4.xlsm
AJ
2Nombre y domicilio del porteador
3Marca y numero
4Marcas y numeros de los bultos
5Placa de Camion
6Cantidad de bultos
7Placa:
8Remitente
9Destinatario
10Consignatario
11Peso bruto (kg.)
12Fecha Emision
Copy


The code is the following.

Thanks in advance

VBA Code:
Sub Cleanup()

Set rMirc = Sheets("Table 1").Range("A1")
Set rMirc = rMirc.Resize(Sheets("Table 1").UsedRange.Rows.Count, Sheets("Table 1").UsedRange.Columns.Count)

iRows = rMirc.Rows.Count
iColumns = rMirc.Columns.Count

           
For iCol = 1 To 1 'iColumns
    For iRow = 1 To iRows
        rData = rMirc.Cells(iRow, iCol).Value
        If rData = "" Then GoTo DoNext
        For Each rCriteria In Range("rCriteria").Cells
            rData = rMirc.Cells(iRow, iCol).Value
            iCriteria = rCriteria.Value
            vSearchFor = "*" & iCriteria & "*"
           
            If rData Like vSearchFor Then
                           
                Sheets("BLANK").Range("A1").Offset(COUNTER, 0).Value = rData

                COUNTER = COUNTER + 1
               
            End If


        Next rCriteria
    Next iRow
Next iCol

End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,215,110
Messages
6,123,146
Members
449,098
Latest member
Doanvanhieu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top