Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi, I am having trouble writing a macro. I need to search the data i 'Sheet2' and sort the data by value into separate worksheets. So i column A if the value of a cell is 9 the data will be pasted int Worksheet'9-10', if the value of a cell is 10, the data will be paste 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, Andre -- Shandy72 ----------------------------------------------------------------------- Shandy720's Profile: http://www.excelforum.com/member.php...fo&userid=2623 View this thread: http://www.excelforum.com/showthread.php?threadid=39526 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Trouble Sorting Spreadsheet | Excel Worksheet Functions | |||
Sorting trouble | Excel Discussion (Misc queries) | |||
Trouble with sorting and Worksheet protect | Excel Discussion (Misc queries) | |||
Trouble with Sorting Hyperlinks | Excel Discussion (Misc queries) | |||
Trouble sorting linked worksheet - need help | Excel Discussion (Misc queries) |