Some help with Active Filtering and copying.


Posted by John S on October 22, 2001 5:18 AM

This macro copies from brief.xls and detect.xls to summary.xls.

I am trying to copy only column R and column W from detect.xls to
column M and N in Summary.xls and only these columns.

Then from brief.xls copy column A, B and D to Summary.xls columns
D, E and F respectively. And no other columns.

Thanks in advance to anyone who can help out. I think its close.
Right now it's copying more than just the desired columns from the
source files.

Sub Transfer()
Dim wb1 As Workbook, wb2 As Workbook
Dim sSheet As Worksheet, dSheet As Worksheet
Dim sRng As Range, dRng As Range

Set wb1 = Workbooks("brief.xls")
Set wb2 = Workbooks("Summary.xls")

Set sSheet = wb1.Sheets("Sheet1")
Set dSheet = wb2.Sheets("Sheet1")

Set sRng = sSheet.Range(sSheet.Range("R2"), sSheet.Range("R65536").End(xlUp))
Set dRng = dSheet.Range("M65536").End(xlUp).Offset(1, 0)
sRng.Copy dRng

Set sRng = sSheet.Range(sSheet.Range("W2"), sSheet.Range("W65536").End(xlUp)).Resize(, 7)
Set dRng = dSheet.Range("N65536").End(xlUp).Offset(1, 0)
sRng.Copy dRng

Set wb1 = Workbooks("detect.xls")
Set sSheet = wb1.Sheets("Sheet1")

Set sRng = sSheet.Range(sSheet.Range("A2"), sSheet.Range("A65536").End(xlUp))
Set dRng = dSheet.Range("D65536").End(xlUp).Offset(1, 0)
sRng.Copy dRng

Set sRng = sSheet.Range(sSheet.Range("B2"), sSheet.Range("B65536").End(xlUp))
Set dRng = dSheet.Range("E65536").End(xlUp).Offset(1, 0)
sRng.Copy dRng

Set sRng = sSheet.Range(sSheet.Range("D2"), sSheet.Range("D65536").End(xlUp)).Resize(, 7)
Set dRng = dSheet.Range("F65536").End(xlUp).Offset(1, 0)
sRng.Copy dRng

Range("G4:I6").Select
Selection.delete Shift:=xlUp

End Sub



Posted by Geoffrey Hurst on October 23, 2001 2:35 AM


SHOULD BE :-
Set sRng = sSheet.Range(sSheet.Range("W2"), sSheet.Range("W65536").End(xlUp))


SHOULD BE :-
Set sRng = sSheet.Range(sSheet.Range("D2"), sSheet.Range("D65536").End(xlUp))


See amendments above.