chocoholic1973
New Member
- Joined
- Mar 21, 2010
- Messages
- 4
I have a portion of a macro that is giving me strange results. What it is supposed to do is autofilter by the first column (numerical value) and copy those lines to a new worksheet. When I copy the visible cells, it is changing the header lines to TRUE. The red line below is where it is happening. Anyone have any suggestions? Is it the macro itself or something with my computer? I need it to be able to run on 2007 sp1.
With wsSheet
Set rnStart = .Range("A1")
Set rnData = .Range(.Range("B1"), .Range("K65536").End(xlUp))
End With
For i = 1 To B
wsSheet.Select
'Here we filter the with the first criterial.
rnStart.AutoFilter field:=1, Criteria1:=i
'Copy the filtered list
rnData = Selection.SpecialCells(xlCellTypeVisible).Copy
'Add a new worksheet to the active workbook.
Worksheets.Add Before:=wsSheet
'Name the added new worksheets.
ActiveSheet.Name = i
'Paste the filtered list.
ActiveSheet.Paste
Range("A1").Select
ActiveSheet.Name = i
Next i
End Sub
With wsSheet
Set rnStart = .Range("A1")
Set rnData = .Range(.Range("B1"), .Range("K65536").End(xlUp))
End With
For i = 1 To B
wsSheet.Select
'Here we filter the with the first criterial.
rnStart.AutoFilter field:=1, Criteria1:=i
'Copy the filtered list
rnData = Selection.SpecialCells(xlCellTypeVisible).Copy
'Add a new worksheet to the active workbook.
Worksheets.Add Before:=wsSheet
'Name the added new worksheets.
ActiveSheet.Name = i
'Paste the filtered list.
ActiveSheet.Paste
Range("A1").Select
ActiveSheet.Name = i
Next i
End Sub