Aggregating data
I managed to fix the problem by incorporating the SourceFile and TargetFile
definition into the step leading up to the sub. (Note: also changed
xlPasteValuesAndNumberFormats).
The code simplifies to:
'Copy FieldNamesRange to FieldNamesDestination
rgFieldNamesRange.copy
rgFieldNamesDestination.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Transpose:=stTranspose
'Copy DataRange to DataDestination
rgDataRange.copy
i = rgDataRange.Rows.Count
j = rgDataRange.Columns.Count
If stBelow = True Then
If stTranspose = True Then
rgDataDestination.Cells((Run - 1) * j + 1, 1).PasteSpecial
Paste:=xlPasteValuesAndNumberFormats, Transpose:=stTranspose
Else
rgDataDestination.Cells((Run - 1) * i + 1, 1).PasteSpecial
Paste:=xlPasteValuesAndNumberFormats, Transpose:=stTranspose
End If
Else
If stTranspose = True Then
rgDataDestination.Cells(1, (Run - 1) * i + 1).PasteSpecial
Paste:=xlPasteValuesAndNumberFormats, Transpose:=stTranspose
Else
rgDataDestination.Cells(1, (Run - 1) * j + 1).PasteSpecial
Paste:=xlPasteValuesAndNumberFormats, Transpose:=stTranspose
End If
End If
Application.CutCopyMode = False
Regards,
JvL
|