to change range of the macro

Brass Contributor

i use bellow macro to auto filter my data on "Stock Detail" sheet. i have some numbers in my "ID" sheet and i use bellow to filter data of stock detail sheet. here with data about ID numbers in the sheet "ID" Column "ID info" Cell "D2" . how can i set the range doe D column (ID Info)

 

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
With Worksheets("Stock Detail")
.Select
.Range("A4").AutoFilter Field:=1, Criteria1:=Target.Value
End With
End Sub

1 Reply

@Ravindu94 

Hi ,

try this

 

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
With Worksheets("Stock Detail")
.Select
.Range("A:D").AutoFilter Field:=4, Criteria1:=Target.Value
End With
End Sub

 

Regards

Bernd

www.vba-tanker.com