Array dimension Not Correct

Hashiru

Active Member
Joined
May 29, 2011
Messages
286
Hi All,

I have the code below:

Code:
Sub CodeCleanUP()


Dim Src As Worksheet, Dst As Worksheet, Code As Worksheet
Set Src = Worksheets("SBBillingExport"): Set Dst = Worksheets("CurrentServices"): Set Code = Worksheets("Codes")
Src.Activate


Dim CodesInspected() As Variant


'Initialize Codes
Dim Code01() As Variant
[COLOR=#b22222]Code01() = Code.Range(Code.Cells(3, 1), Code.Cells(Code.Cells(Rows.Count, 1).End(xlUp).Row, 1))[/COLOR]


RCount = Src.Cells(Rows.Count, 1).End(xlUp).Row
Src.Columns("R:R").Delete Shift:=xlToLeft
Src.Range("B1:B" & RCount).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Src.Range("R1"), Unique:=True
Clients = Src.Cells(Rows.Count, 18).End(xlUp).Row


Src.Cells(2, 18).Resize(Clients - 1, 1).Copy Dst.Cells(2, 1)


For i = 2 To Clients
    ClientID = Src.Cells(i, 18)
    Src.Range("A1:P" & RCount).AutoFilter
    Src.Range("$A$1:$P" & RCount).AutoFilter Field:=2, Criteria1:=ClientID
  
            'StartProc = GetFilteredRangeTopRow
            'EndPRoc = GetFilteredRangeBottomRow
            
            Dst.Cells(i, 1) = ClientID
            For j = StartProc To EndPRoc
                Dst.Cells(i, 2) = Src.Cells(j, 4)
                'NextRow = Dst.Cells(Rows.Count, 2).End(xlUp).Row
                                
                For k = LBound(Code01) To UBound(Code01)
                    If Trim(Code01(k, 1)) = Left(Src.Cells(j, 10), 6) Then
                        Dst.Cells(i, 3) = "Yes"
                    End If
                Next k
            Next j


Next i
Src.Range("A1:P" & RCount).AutoFilter


End Sub
The highlighted line of code suppose to assign the specified range of values as a one dimensional array using the row values in the range but it is creating arrays from the horizontal values. i.e. instead of a x rows by 1 column dimension, I am have 1 row by x column dimension and strictly multi-direction instead of one dimensional

Need help to resolve this.
 
Last edited:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
what about:
Code:
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Code01 = Range(Cells(3, 1), Cells(lastrow, 1))
 
Upvote 0
If you want a 1d array try
Code:
Dim Code01 As Variant
Code01 = Application.Transpose(Code.Range("A3", Code.Range("A" & Rows.Count).End(xlUp)))
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,172
Members
448,554
Latest member
Gleisner2

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