Hi all

I have got the following code, I am trying to firstly set the last row's number of the current region as a variable n. At the moment I have no idea how to do this as is probably apparent below!

Then I need to reference the row number n+2 in column 1 for that is where advanced filter criteria will appear, but I don't think it's working just writing n+2... Any help would be much appreciated!

Thanks a million to all the legends who have helped me before!

Alek

I have got the following code, I am trying to firstly set the last row's number of the current region as a variable n. At the moment I have no idea how to do this as is probably apparent below!

Then I need to reference the row number n+2 in column 1 for that is where advanced filter criteria will appear, but I don't think it's working just writing n+2... Any help would be much appreciated!

Code:

Sub regionend() Range("A1").Select ActiveCell.CurrentRegion.Select n = ActiveCell.Row 'this sets n to 1 but I need to set it 'to row number of last row in current region Filter_defineranges End Sub Sub Filter_defineranges() ActiveWorkbook.Names.Add Name:="paste", RefersToR1C1:="=Sheet2!R1C1" With Sheet1 .Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, _ CriteriaRange:=.Range( _"n+2,1").CurrentRegion, Unique:=False _ 'the above "n+2, 1" reference to a cell doesn't seem to be correct either, 'so I need to reference this correctly also! .Range("Data").SpecialCells(xlCellTypeVisible).Copy Destination:="PasteRange" .ShowAllData End With End Sub

Alek

## Comment