View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Cimjet[_3_] Cimjet[_3_] is offline
external usenet poster
 
Posts: 157
Default Newbie help needed please...

Hi ML
I'm not sure what you want but if I understand this should work.
Sub loopY()
Dim sh2 As Worksheet
Set sh2 = Sheets("Sheet2")
finalrow = Cells(65536, 1).End(xlUp).Row
For i = 1 To finalrow
If Cells(i, 3).Value = "y" And Cells(i, 4).Value < 0 Then
Lastrow = sh2.Cells(Cells.Rows.Count, 1).End(xlUp).Row
Cells(i, 1).Resize(1, 2).Copy Destination:=sh2.Cells(Lastrow + 1, 1)
End If
Next i
End Sub
==========
You need to have a "y" in column C and something in column D to copy.
HTH
Cimjet

"ML" wrote in message
nd.com...
Hello and thank you Cimjet

Even though my boss does not want me using VB, I tried your code and it works
very nicely which has softened my boss up a little....lol....

I was wondering if it is possible to expand the IF to include a secondary
criteria.

Using a snippet of your code, is it possible to do this:
I know I did not mention Column ("D") prior as it I did not think it important
( at the time ).

If Cells(i, 4).value = "NotBlank" or Cells(i, 3).value= "Y".

So if Column 4 is blank, then it needs to look at Column 3, if both criteria
match then it copies.

Meaning that if Column ("D") is Blank then it should jump to the next row, the
same is true in the opposite, if ("D") is NotBlank and ("C") ="" then it to
will mean the code should step over to the next row until the end.

I hope this is not too confusing and that I have explained it clearly and or
if it is at all possible.

Thank you again for all your help.

Mark.