Just trying to capture data in a loop

hitbid

Board Regular
Joined
Jan 21, 2016
Messages
114
I am doing an exercise where I am searching countless data entries in a bad format and finding what I need. Below is very sample data. I can find the midway point all the time fine. But it is getting the data between MidwayPoint and NewStart.
I tried IF statements but keep getting locked up, and the fact that the data here isn't always stacked neatly. Sometimes spaces jump in like you see below.
How Can I best loop to always capture all the data between MP and NS?

Start
data
data
data
data
data
Midway Point
data
data
data
NewStart
data
data
data

<tbody>
</tbody>

Code:
    indi = 1
For i = 1 To lastrow
    If (InStr(1, inarr(i, 1), "Invoice # S", vbTextCompare)) > 0 Then
        If (InStr(1, inarr(i + 7, 1), "Shipping Instr :", vbTextCompare)) > 0 Then
                    If WorksheetFunction.CountA(inarr(i + 8, 1)) > 0 Then
                    Num8 = inarr(i + 8, 1)
                    ElseIf WorksheetFunction.CountA(inarr(i + 8, 1)) = 0 Then
                    Num8 = ""
                    End If
                    If (InStr(1, inarr(i + 7, 1), "Shipping Instr :", vbTextCompare)) = 0 Then
                    Num8 = ""
                    End If
        Num7 = Trim(Split(inarr(i + 7, 1), "Shipping Instr :")(1))
        Else: Num7 = ""
        End If
    outarr(indi, 6) = Num7 & Num8
    indi = indi + 1
    End If
Next i

<tbody> </tbody>
 
Last edited:

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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