Hi,
I am having trouble writing a macro. I need to search the data in 'Sheet2' and sort the data by value into separate worksheets. So in column A if the value of a cell is 9 the data will be pasted into Worksheet'9-10', if the value of a cell is 10, the data will be pasted into Worksheet'10-11' and so on...
This is the macro i have so far which will not work;
Sub STEP3()
Dim rng As Range, cell As Range, sel As Range
Set rng = Intersect(Range("A:A"), Sheets("Sheet2").UsedRange)
For Each cell In rng
If (cell.Value) = "9" Then
sel.EntireRow.Select
Application.CutCopyMode = False
Selection.Copy
Sheets("9-10").Select
Range("A3").Select
ActiveSheet.Paste
If (cell.Value) = "10" Then
sel.EntireRow.Select
Application.CutCopyMode = False
Selection.Copy
Sheets("10-11").Select
Range("A3").Select
ActiveSheet.Paste
If sel Is Nothing Then
Set sel = cell
Else: Set sel = Union(sel, cell)
On Error Resume Next
End If
End If
End If
Next
End Sub
Please can you help, Many thanks,
Andrew
Bookmarks