Thanks for your reply Stephen, I hope I'm able to explain better!
Example1.xls is attached, and shows some of the data, together with two additional sheets detailing certain departments. Both sets of departments are defined as names (codeY and codeZ) and as such if you do an advanced filter on the data, with the criteria of either, it returns all the appropriate rows. This is correct!
Example2.xls contains a macro, which is to be run when in the data sheet. This performs an advanced filter using criteria codeZ, which works fine. It should then attempt to paste the letter Z into the top row of the filtered results in the Code column, and then select the remaining rows and copy down to them. Thus, all of the departments that are code Z automatically have the Z put in the Code field!
However, the macro code doesn't like to be vague, which is causing a problem. I want the macro to say, after selecting the criteria, "go to the top of the selected criteria, and click on whatever cell that is within the Code column, put in a Z, copy and paste to all other cells". However, Excel interprets this as "go to E2, put in a Z, copy and paste to all other cells". This workbook will be taking lots of different data, and E2 won't always be a code Z, just like it won't always be a Y or any other code. However, Excel appears to want to force it to be a specific cell reference, rather than just the top of the filtered results. Can you help?
Bookmarks