Copy IF condition exists

  • Thread starter Thread starter Office_Novice
  • Start date Start date
O

Office_Novice

Is it possiable to Copy and paste if a specific condition exists?

Heres the problem in column "F" there is a number. If that number is less
then 61 i would like to move the entire row to another sheet. also the range
will change with the data. can this be done?
 
Something like:
If Range("F5").Value<61 Then
'Your code to move/copy whatever you want.
End If
You will probably need more than that if you want to "move" the entire row
rather than just copy it.
HTH Otto
 
Well Thats a good start thanks, if i could bother you for one more? Rather
then spend the rest of my life typing this over and over
Sub newone()
If Range("F1").Value < 61 Then
Sheets("Sheet1").Select
Rows("1:1").Select
Selection.Copy
Sheets("Sheet2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
End If
If Range("F2").Value < 61 Then
Rows("2:2").Select
Selection.Copy
Sheets("Sheet2").Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Sheets("Sheet1").Select
End If
Could this be put in a loop to Do....Until There are no numbers < 61?
 
Maybe something like this: HTH Otto
Sub newone()
Dim RngColF As Range
Dim i As Range
Dim Dest As Range
Sheets("Sheet1").Select
Set RngColF = Range("F1", Range("F" & Rows.Count).End(xlUp))
With Sheets("Sheet2")
Set Dest = .Range("A1")
End With
For Each i In RngColF
If i.Value < 61 Then
i.EntireRow.Copy Dest
Set Dest = Dest.Offset(1)
End If
Next i
End Sub
 
So Far so Good thanks Otto!

Otto Moehrbach said:
Maybe something like this: HTH Otto
Sub newone()
Dim RngColF As Range
Dim i As Range
Dim Dest As Range
Sheets("Sheet1").Select
Set RngColF = Range("F1", Range("F" & Rows.Count).End(xlUp))
With Sheets("Sheet2")
Set Dest = .Range("A1")
End With
For Each i In RngColF
If i.Value < 61 Then
i.EntireRow.Copy Dest
Set Dest = Dest.Offset(1)
End If
Next i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top