Home

to change range of the macro

Ravindu94
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

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
38 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
29 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies