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?

[TABLE="width: 93"]
<tbody>[TR]
[TD]Start[/TD]
[/TR]
[TR]
[TD]data[/TD]
[/TR]
[TR]
[TD]data[/TD]
[/TR]
[TR]
[TD]data[/TD]
[/TR]
[TR]
[TD]data[/TD]
[/TR]
[TR]
[TD]data[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Midway Point[/TD]
[/TR]
[TR]
[TD]data[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]data[/TD]
[/TR]
[TR]
[TD]data[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]NewStart[/TD]
[/TR]
[TR]
[TD]data[/TD]
[/TR]
[TR]
[TD]data[/TD]
[/TR]
[TR]
[TD]data[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 93"]
<tbody>[TR]
[TD]
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
[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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