PDA

View Full Version : Copy range in new sheet by criteria



teodormircea
07-23-2008, 02:14 AM
Hello forum

I need your help for a little project.

I want to copy a range of data in a new sheet using a criteria. First i would like to choose a column, and second the criteria.If criteria in this column is meet , copy all rows in the range that meet that criteria in a new sheet named after the criteria

mdmackillop
07-23-2008, 04:25 AM
Have a look at this question (http://vbaexpress.com/forum/showthread.php?t=21059).

teodormircea
07-23-2008, 05:45 AM
Here a chopped code , but is not working, some help pls

Sub ANALYSE_LEDGER()


Dim X As Integer

Dim cc As String
Dim c As Range
Dim lRow As Long
Dim NewWB As Workbook


Application.ScreenUpdating = False
Set NewWB = Workbooks.Add
col = Application.InputBox("No colonne?", Type:=1)
Set champ = Columns(col)
cc = InputBox(Prompt:="Chose Criteria")

For Each c In champ.SpecialCells(xlCellTypeConstants, 66)

If cell.Value Like "*" & c & "*" Then
Range(Cells(c.Row, 1), Cells(c.Row, 66)).Copy

NewWB.Activate
lRow = lRow + 1
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Cells(lRow, 1)

End If

Next c

End Sub