Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Pedro Gilbert   on Feb 22 In MS Office Category.

  
Question Answered By: Renee Lane   on Feb 22

You can try the following:

Application.ScreenUpdating = False
Sheets.Add.Name = ("SheetX")
Sheets("SheetX").Move After:=Sheets(Sheets.Count)
Sheets.Add.Name = ("SheetY")
Sheets("SheetY").Move After:=Sheets(Sheets.Count)

Dim LastCell As Range
Set LastCell = Worksheets("Sheet1").Range("C1")
Do Until IsEmpty(LastCell)
If LastCell.Value = "X" Then
LastCell.EntireRow.Copy
Sheets("SheetX").Select
Range("C65536").End(xlUp)(2, -1).Select
ActiveSheet.Paste
LastCell.EntireRow.Delete
Set LastCell = Worksheets("Sheet1").Range("C1")
End If
If LastCell.Value = "Y" Then
LastCell.EntireRow.Copy
Sheets("SheetY").Select
Range("C65536").End(xlUp)(2, -1).Select
ActiveSheet.Paste
LastCell.EntireRow.Delete
Set LastCell = Worksheets("Sheet1").Range("C1")
End If
If LastCell.Value <> "X" Then
If LastCell.Value <> "Y" Then
Set LastCell = LastCell(2, 1)
End If
End If
Loop
Application.ScreenUpdating = True

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Newbie VB help? Or get search suggestion and latest updates.


Tagged: