Results 1 to 3 of 3

Transferring part of a large array to smaller array

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-29-2008
    Location
    New York
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    145

    Transferring part of a large array to smaller array

    Good day,
    I'm trying to transfer a part of a large array to a smaller array and then put it to a spreadsheet range, but it is not working for me.
    Here is the code:
    'This code does not work.
    Sub Mcr_ii()
        Dim x As Variant
        Dim y As Variant
        Dim r As Long, c As Long
        Dim rCel As Integer: rCel = 1
        Dim lRow As Long: lRow = Sheets("DBase").Cells(Rows.Count, 1).End(xlUp).Row
        Dim iCount As Long
        iCount = Application.CountIf(Sheets("DBase").Range("E:E"), "B")
        x = Sheets("DBase").Range("A2:F" & lRow)
    
        ReDim y(1 To iCount, 1 To 6)
    
        For r = 1 To UBound(x, 1)
            For c = 1 To UBound(x, 2)
                If x(r, 5) = "B" Then
                    y(r, c) = x(rCel, c) '/ Trying to make the data that fits the criteria fit into a smaller array.
                End If
                rCel = rCel + 1
            Next c
        Next r
    '/ Transfer to spreadsheet.
        Sheets("CO-A").Range("A1:F" & iCount) = y
    End Sub
    I've attached a workbook.
    Help me to understand what I'm doing wrong.
    Thanks,
    Xrull
    Attached Files Attached Files
    Last edited by Xrull; 06-26-2011 at 09:40 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1