Pete634
02-24-2009, 03:50 PM
A master workbook contains four cells, F4:F7 on Sheet 2 which contain text relevant to text on 4 other workbooks.
I'm trying to filter each of the other workbooks based on the value of each of the 4 cells seperately, obtaining the numercial value from two subtotal cells at the end of each worksheet which is pasted into the Master workbook before moving onto the next workbook.
I'm OK with doing the pasting bit but I'm struggling with the code for the autofilter. What I have so far is...
Dim Range1 as Variant
'................
'....code activates relevant workbook and then selects relevant worksheet
Range1 = thisworkbook.sheets(2).range("F4:F7")
For Each cell in Range1
selection.autofilter Field:=12, Criteria1:=cell.value
'.... more code etc
Next cell
Can anyone help? I'd normally post the workbook but I don't really think this time it's necessary as it's only the above part that I can't get to work and I'm confident someone will know what I clearly don't!
Thanks
I'm trying to filter each of the other workbooks based on the value of each of the 4 cells seperately, obtaining the numercial value from two subtotal cells at the end of each worksheet which is pasted into the Master workbook before moving onto the next workbook.
I'm OK with doing the pasting bit but I'm struggling with the code for the autofilter. What I have so far is...
Dim Range1 as Variant
'................
'....code activates relevant workbook and then selects relevant worksheet
Range1 = thisworkbook.sheets(2).range("F4:F7")
For Each cell in Range1
selection.autofilter Field:=12, Criteria1:=cell.value
'.... more code etc
Next cell
Can anyone help? I'd normally post the workbook but I don't really think this time it's necessary as it's only the above part that I can't get to work and I'm confident someone will know what I clearly don't!
Thanks