Hello.
I'm trying to run some code so that when a certain cell is clicked, you go to another sheet and it runs an advanced filter... I've even given up on this and tried an autofilter but no joy. It will not let me select a cell in the new sheet (because I am running code from 1st sheet?). When I run the advanced filter, I get no matches, even though I know they are there.
this gives me an empty table. If I then go into sheet 3 and run the advanced filter myself, I get the rows matching my criteria (in row 2).
Can anyone help?
I tried using autofilter but it filtered the original sheet so I tried
but this doesn't do anything. (recording gives 'Selection.Auto...' but I can't select any cells)
Thanks for your time.
Additional:
I started this with two different workbooks and the code opened what is now contained in sheet(3). I had the issue with advanced filtering not giving any results and so tried combining the sheets. Now that I have, I realise that line
doesn't work either.
I'm having a complete failure.
I'm trying to run some code so that when a certain cell is clicked, you go to another sheet and it runs an advanced filter... I've even given up on this and tried an autofilter but no joy. It will not let me select a cell in the new sheet (because I am running code from 1st sheet?). When I run the advanced filter, I get no matches, even though I know they are there.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 18 Then
If Target.Cells.Value = "Y" Then
RR = Target.Row
Sheets(3).Range("a2").Value = Sheets(1).Cells(RR, 3)
Sheets(3).Range("h2").Value = ""
Sheets(3).Range("i2").Value = ""
Sheets(3).Range("m2").Value = ""
Sheets(3).Range("p2").Value = ""
Sheets(3).Range("n2").Value = "Y"
Sheets(3).Activate
Sheets(3).Range("A11:Q10000").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Rows("1:2"), Unique:=False
End If
End If
End Sub
this gives me an empty table. If I then go into sheet 3 and run the advanced filter myself, I get the rows matching my criteria (in row 2).
Can anyone help?
I tried using autofilter but it filtered the original sheet so I tried
Code:
Sheets(3).Range("A11").AutoFilter Field:=1, Criteria1:=Sheets(1).Cells(RR, 3)
Thanks for your time.
Additional:
I started this with two different workbooks and the code opened what is now contained in sheet(3). I had the issue with advanced filtering not giving any results and so tried combining the sheets. Now that I have, I realise that line
Code:
Sheets(3).Range("a2").Value = Sheets(1).Cells(RR, 3)
I'm having a complete failure.
Last edited: