0

I have a Log file which I have imported to Excel and I have filtered Col C based on a Criteria. Now I want to search through Col E for "TRUE". For every instance of "TRUE", I want to select the rows above it for Col D,E until I find an empty cell in Col E, copy those and paste it into a new worksheet in the same workbook.

enter image description here

As per the picture above, I want to copy Rows 9 to 1 in worksheet1 and Skip copying Rows 20 to 10 (Because Col E has FALSE) and copy rows 31 to 21 in worksheet2.

4
  • Good Day, Welcome to StackOverflow. Please could you paste your current code for what you want to do, this will help the users to look at where you can be assisted. Generally, this site is not for users to ask for someone to develop some code for them. Commented Nov 27, 2015 at 8:37
  • If you want help to develop a code for your idea. Then start with a Loop to run thought the columns and the If you find what you are looking for start another Loop to search up for the required text. Then assign that Range and copy it to the new sheet. Commented Nov 27, 2015 at 8:39
  • 1
    Do you mind sharing with us your first macro attempt, so we can help you to progress with it. BTW what your are trying to do can easily be done with a formula in column E, then AutoFilter and copy visible cells to the target sheet... Commented Nov 27, 2015 at 17:42
  • Thanks for the replies.. I am able to do it with google nd this forum's help, Commented Dec 4, 2015 at 12:07

1 Answer 1

1

You can use .areas

This is a tough one if you have no VBA experience and don't know what to look for. Here is a head start, based on the picture you have supplied I came up with this.

Sub DoIt() Dim sh As Worksheet, ws As Worksheet Dim RangeArea As Range, c As Range Set sh = ActiveSheet Application.ScreenUpdating = 0 With sh For Each RangeArea In .Columns("E").SpecialCells(xlCellTypeConstants, 23).Areas Set c = RangeArea.Find(what:="TRUE", lookat:=xlWhole) If Not c Is Nothing Then RangeArea.EntireRow.Copy Sheets.Add ActiveSheet.Paste Else End If .Select Next RangeArea End With Application.CutCopyMode = 0 End Sub 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.