Array Output

cortexnotion

Board Regular
Joined
Jan 22, 2020
Messages
150
Office Version
  1. 2013
Platform
  1. Windows
Hi All

Below is a snippet of my code to filter data (no issues there). I have to list my output array column order one by one - is there a one-liner to paste the array in the column order I want?

Thanks!

VBA Code:
ReDim ArrOUT(1 To LR1, 1 To 14)
o = 1

For i = LBound(ArrIN) To UBound(ArrIN)

If InStr(ArrIN(i, 2), "CU ") = 0 And InStr(ArrIN(i, 8), "Water") > 0 And _
ArrIN(i, 9) > 0 And ArrIN(i, 16) > 0 Then

For b = LBound(BucketArray) To UBound(BucketArray)
If InStr(ArrIN(i, 2), BucketArray(b)) > 0 Then GoTo NR1
Next b

For m = LBound(MatchArray) To UBound(MatchArray)
If InStr(ArrIN(i, 3) & ArrIN(i, 4), MatchArray(m)) > 0 Then GoTo NR1
Next m

ArrOUT(o, 1) = ArrIN(i, 2)
ArrOUT(o, 2) = ArrIN(i, 3)
ArrOUT(o, 3) = ArrIN(i, 4)
ArrOUT(o, 4) = ArrIN(i, 6)
ArrOUT(o, 5) = ArrIN(i, 7)
ArrOUT(o, 6) = ArrIN(i, 9)
ArrOUT(o, 7) = ArrIN(i, 11)
ArrOUT(o, 8) = ArrIN(i, 16)
ArrOUT(o, 9) = ArrIN(i, 18)
ArrOUT(o, 10) = ArrIN(i, 19)
ArrOUT(o, 11) = ArrIN(i, 21)
ArrOUT(o, 12) = ArrIN(i, 22)
ArrOUT(o, 13) = ArrIN(i, 23)
ArrOUT(o, 14) = ArrIN(i, 24)
o = o + 1
End If
NR1:     Next I

Sheets("BOBJ").Range("A3:N3").Resize(UBound(ArrOUT)).Value = ArrOUT
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
You could us another loop along the lines of
VBA Code:
Dim ColAry As Variant
ColAry = Array(2, 3, 4, 6, 7, 9, 11, 16, 18, 19, 21, 22, 23, 24)
For i= LBound(ArrIN) To UBound(ArrIN)
.
.
.

For x = 0 To UBound(ColAry)
   arrOUT(o, x + 1) = arrIN(i, ColAry(x))
Next x
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,365
Messages
6,124,513
Members
449,168
Latest member
CheerfulWalker

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