Hi all
I have used the below code for a while, but it sometimes outputs values in a cell when its not supposed to.
i got help creating this code in this forum a while ago
Sub tgr()
Dim rng(1 To 3) As Range
Dim i As Long
For i = 1 To 3
Set rng(i) = Intersect(Sheets("KommentarBackup").UsedRange, Sheets("KommentarBackup").Columns(i))
Next i
With Sheets("Ordre").Range("L4:L" & Sheets("Ordre").Cells(Rows.Count, "A").End(xlUp).Row)
.Formula = "=IFERROR(INDEX(KommentarBackup!" & rng(3).Address & ",SUMPRODUCT(--(A4=KommentarBackup!" & rng(1).Address & "),--(B4=KommentarBackup!" & rng(2).Address & "),ROW(KommentarBackup!" & rng(3).Address & "))),"""")"
.Value = .Value
End With
End Sub
What this code does is mathing row A and B in sheet "ordre" with row A and B in sheets "kommentarbackup" and
copies row C from "kommentarbackup" to row L "ordre" in column where both matches.
I think that my problem is when i have a row A and B that doesnt match - i think in these cases the formula copies the corresponding row anyway - (example : now match row A and B "ordre" row 265 : copies row C "kommentarbackup" row 265 to row L "ordre" row 265. Not sure though
ill paste the link to my original post for further explanation :
http://www.excelforum.com/excel-prog...-in-range.html
Bookmarks