Selected Answer
Sue
From the Discussion above, it seems your question .xlsm file didn't include the new Report format (so Willie and I found no error).
In the first attached file below, I deleted the existing Sheet0 and copied Sheet0 from the Report.xlsx file to that file.
I then found that a runtime error 1004 occurred because -when writing the first column (with n=1) - the array element ColXRef(1, 2) was emptyso .Cells(2, ColXRef(n, 2) would evaluate to .Cells(1,0) which doesn't exist in Excel since there is no column 0.
I think I fixed it using the simple expedient of setting it to 1 when n=1 and the array element is empty, as in bold in the code extract below:
' #4. Copy data from source to report using cross refs
' go across headers
For n = 1 To RepLstCl
' if first column or there's a cross ref to source
If n = 1 Or Not IsEmpty(ColXRef(n, 2)) Then
' when n=1 set value to 1
If IsEmpty(ColXRef(n, 2)) Then ColXRef(n, 2) = 1
' copy source rows 2 to end
With Sheets(2)
Set CpyRng = .Range(.Cells(2, ColXRef(n, 2)), .Cells(SrcLstRw, ColXRef(n, 2)))
CpyRng.Copy Destination:=Sheets(1).Cells(3, n)
End With
Else
'otherwise collect headings not imported
NoX = NoX & ColXRef(n, 1) & vbCr
End If
' write borders and fill background like header
With Sheets(1).Range(Cells(3, n), Cells(SrcLstRw + 1, n))
.Borders.LineStyle = xlContinuous
.Interior.Color = Sheets(1).Cells(1, n).Interior.Color
End With
Next n
The button now runs without problem (and the missing refs are reported as before).
Hope this fixes your problem- if so, please remember to mark this Answer as Selected.