isabelarodriigs
New Member
- Joined
- Jan 14, 2025
- Messages
- 7
- Office Version
- 365
- Platform
- Windows
- MacOS
- Mobile
- Web
I would like to to click on on my sheet 1 in excel and automatically filter on my third sheet. I using this code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Intersect(Target, Range("A:C")) Is Nothing Then Exit Sub
With Sheets("mydata").Cells(7, 1).CurrentRegion
.AutoFilter 1, Target.Offset(, -1)
.AutoFilter 2, "Completed"
End With
End Sub
but when i double click, i get to run-time error '9'. Subscript out of range. Then it highlights this part With Sheets("mydata").Cells(7, 1).CurrentRegion
saying that table does not exist, but it does.
this is my sheet 1:
my second sheet:
I want to click on sheet 1, column C, and filter automatically sheet2, column G.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Intersect(Target, Range("A:C")) Is Nothing Then Exit Sub
With Sheets("mydata").Cells(7, 1).CurrentRegion
.AutoFilter 1, Target.Offset(, -1)
.AutoFilter 2, "Completed"
End With
End Sub
but when i double click, i get to run-time error '9'. Subscript out of range. Then it highlights this part With Sheets("mydata").Cells(7, 1).CurrentRegion
saying that table does not exist, but it does.
this is my sheet 1:
|
|
|
|
| |||||
|
|
|
|
my second sheet:
CUSTOMER ID | CUSTOMER NAME | DISTRICT ID | DISTRICT NAME | DIVISION ID | DIVISION NAME | DEPARTMENT ID |
LLUHS | LOMA LINDA UNIVERSITY HEALTH SYSTEM | LA | LOS ANGELES, CA | LLUMC | LOMA LINDA UNIVERSITY MEDICAL CTR | 8154 |
I want to click on sheet 1, column C, and filter automatically sheet2, column G.