Below is a my called code. It is being called into a code that asks user to open a desired workbook. The called code works properly when I step it through using F8 but it fails to create a proper correlation table when I run the code fully.
Dim nCols As Integer
Dim myRange, myCorrel, c As Range
Range("A1").CurrentRegion.Select
nCols = Selection.Columns.Count
Range("B1").Resize(1, nCols - 1).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Set myRange = Selection
' create correlation table
Application.Run "ATPVBAEN.XLAM!Mcorrel", myRange, _
"Statistics", "C", True
Selection.Copy
Range("B1").End(xlToRight).Offset(0, 2).Select
Selection.PasteSpecial
End Sub
My correlation table code fails to capture the data headers. I would receive a bunch of correlation calculated without the original column headers.