Can someone help me with this please?
The macro was kinldy supplied by a member of the forum. I think that this part of the macro is picking up columns A:C rather than just column C.
Can anyone advise on how to change it please?
r.Offset(1, 0).Resize(r.Rows.Count - 1, r.Columns.Count).SpecialCells(xlCellTypeVisible).Copy
Sub test()
Dim j As Integer, k As Integer, r As Range, x As String
Dim m As Integer, n As Integer
k = 11
'k is larget number with /13 and if necessary change it
m = 10 'the first row in which to be copied.if necessary change
n = 50 'difference between te rows in your case it is 50. if necessary change
Workbooks("wkbk1.xls").Activate
Worksheets("test").Activate
Set r = Range(Range("A1"), Cells(Rows.Count, "c").End(xlUp))
'MsgBox r.Address
For j = 1 To k
If j < 10 Then
x = "0" & j & "|13"
Else
x = j & "|13"
End If
'MsgBox x
r.AutoFilter Field:=2, Criteria1:=x
r.Offset(1, 0).Resize(r.Rows.Count - 1, r.Columns.Count).SpecialCells(xlCellTypeVisible).Copy
With Workbooks("wkbk2.xls").Worksheets("sheet1")
'MsgBox .Range("A" & m).Offset((j - 1) * n, 0).Address
.Range("A" & m).Offset(m + (j - 1) * n, 0).PasteSpecial Paste:=xlPasteValues
End With
'Workbooks("wkbk1.xls").Activate
'Worksheets("test").Activate
r.AutoFilter
Next j
End Sub
Bookmarks