Hi, Foxy17!
I took your Small-File-V2.xlsm (which BTW was finely modified), messed it up a little and uploaded as:
http://dl.dropbox.com/u/60558749/Sorting%20with%20Macro%20-Furmula%20dose%20not%20reflect%20previous%20page%20and%20mixes%20up%20results%20-%20Small%20File%20V2%20%28for%20Foxy17%20at%20chandoo.org%29.xlsm
I set up two alternatives (yes, yes, I know what you're thinking...):
First, sheet "Voyage B":
a) replaced search condition 'Voyage A'!E5=0 by:
ISTEXT(VLOOKUP(A5,'Voyage A'!A:G,5,FALSE))
Because of "Not Due" values.
b) replaced IF condition (which caused the problem or changing row because of relative changing addresses) by VLOOKUP functions:
VLOOKUP(A5,'Voyage A'!A:G,5,FALSE) if it wasn't text (ergo, previously completed)
VLOOKUP(A5,'Voyage A'!A:G,4,FALSE) if it was text (ergo, previously not due)
Which in fact looks for column A cell values within range A:G on previous sheet and retrieves 5th column value (E) -and 4th (D)-
c) replaced Date+30 days and EDATE+6 months by unified EDATE+N months, where N is the value for first character of column C cells or a 1 if it isn't numeric (so adopting the same criteria as it wasn't the same Date+30 days than D+1 month):
IF(ISNUMBER(VALUE(LEFT(C5,1))),VALUE(LEFT(C5,1)),1)
Second sheet, "Voyage C":
Same changes as above, but using OFFSET and ADDRESS functions for referencing cells, changing VLOOKUP of previous paragraph by:
INDIRECT(ADDRESS(ROW(),COLUMN()+1,4,1,"Voyage B"))
INDIRECT(ADDRESS(ROW(),COLUMN(),4,1,"Voyage B"))
INDIRECT takes a built address and returns the value of the reference
ADDRESS builds a string reference providing row number, column number, relative (4) format, A1 (1) notation, and related sheet.
It's up to you to choose between sheet 2 or 3 models.
Hope this helps and doesn't confuse you a lot. If so, please advise.
Regards!