View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Maria
 
Posts: n/a
Default Sorting into different worksheets from a unique value

I tried the new code, but it stopped sorting and selected the fourth
row, and I'm not sure why. I have 52 columns and my sorting criteria
is in column 36. Please let me know if something I've changed in the
code does not make sense. Thanks.


Sub Sort()


Dim x, z


On Error Resume Next


Worksheets("Master").Activate


Application.ScreenUpdating = False


Cells(1, 1).Activate


x = 2


Do Until Cells(x, 8).Value = ""


Range(Cells(x, 1), Cells(x, 52)).Copy


Select Case Cells(x, 36).Value

Case "Red"


Worksheets("Red").Activate


Case "Blue"


Worksheets("Blue").Activate


Case "Yellow"


Worksheets("Yellow").Activate


End Select


Cells(1, 1).Activate


If Cells(2, 1).Value = "" Then
z = 2
Else
z = ActiveCell.End(xlDown).Row + 1
End If


Cells(z, 1).PasteSpecial


Worksheets("Master").Activate


x = x + 1 'go to the next row on the Master sheet


Loop


Application.ScreenUpdating = True


End Sub