Ranges with split rows combined into array issue

Darren Smith

Well-known Member
Joined
Nov 23, 2020
Messages
631
Office Version
  1. 2019
Platform
  1. Windows
The code below is to combine arrays with a gap between the ranges.
The array does not fill-in?
Says "Arr error 2015" & RunTime Error 13

VBA Code:
Private Sub Fill_Details_Click()

TurnOff

Dim wsCSheet As Worksheet, JCM As Worksheet
Dim Col As Long, Row As Long
Dim Arr As Variant
Dim A As Integer, B As Integer

    Set JCM = ThisWorkbook.Worksheets("Job Card Master")

      Dim rngItem As Range: Set rngItem = JCM.Range("A13:A61,A66:A122")
       Dim rngDes As Range: Set rngDes = JCM.Range("C13:C61,C66:C122")
        Dim rngAllocHrs As Range: Set rngAllocHrs = JCM.Range("K1:K61,K66,K122")

    Set wsCSheet = ThisWorkbook.Worksheets("Check Sheet")


Dim RngAll As Range: Set RngAll = Union(rngItem, rngDes, rngAllocHrs)
            Arr = Application.Transpose(RngAll)

For Col = LBound(Arr) To UBound(Arr)
  For Row = LBound(Arr, 13) To UBound(Arr, 13)
  Next
    Next
  End If

  B = 12
For A = 12 To Arr

    If JCM.Cells(A, 1) <> "" Then
        Do Until Worksheets("Check Sheet").Cells(B, 2) = ""
        B = B + 1
        Loop
        wsCSheet.Cells(B, 1) = JCM.Cells(A, 1): wsCSheet.Cells(B, 2) = JCM.Cells(A, 3): wsCSheet.Cells(B, 6) = JCM.Cells(A, 11)
    End If
   
Next A

End sub
 
Last edited:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
The code you've posted doesn't make much sense, and doesn't even compile (you've got a superfluous Endif).

What do you want the code to do? It looks like you want to rearrange some input ranges into some other format? If so, perhaps you could show:

a) input, and
b) desired output?
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,702
Members
449,048
Latest member
81jamesacct

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