View Single Post
 
Old 06-25-2011, 12:51 PM
Catalin.B Catalin.B is offline Windows Vista Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

Well, i did find a solution....
Looks Like this:

Sub NextAll()
Dim col As Range, row As Range, Myrange As Range
Set col = Worksheets("Foaie1").Range("J3")

If Worksheets("Foaie1").Range("J3") = 10 Then
Worksheets("Foaie2").Range("A3:A6").Copy
Worksheets("Foaie1").Range("A3").PasteSpecial (xlPasteValues)
Exit Sub
End If
Set Myrange = Range(Worksheets("Foaie2").Cells(3, col), Worksheets("Foaie2").Cells(6, col))
Myrange.Copy
Worksheets("Foaie1").Range("A3").PasteSpecial (xlPasteValues)

On Error GoTo 0
End Sub

This macro depends on evaluation formula in cell "J3", which is:
=IF(ISERROR(MATCH(A3;Foaie2!A3:I3;0)+1)=TRUE;0;MAT CH(A3;Foaie2!A3:I3;0)+1)
To copy row by row instead of a range of rows, just change the copy range to 1 row
I am sure there are better solutions... but this works fine for me, so I will give many thanks to me
I will atach the file again for those interested.
Have a great day
Attached Files
File Type: xlsm test.xlsm (21.3 KB, 14 views)
Reply With Quote