Hi there,
I am trying to create a VBA project that will run on opening a password protected workbook. I want it to populate the username in E1, then to use that username to force filtering Column C, based on a lookup in cell F2 (looking up their actual name based on E1). This is the code I am using, it all works in isolation, but when put together, the Auto filter isn't running. Can anyone help me, please?
Private Sub Workbook_Open()
ActiveSheet.Unprotect "Password"
Dim strUN As String
strUN = Environ("Username")
Worksheets(1).Range("E1").Value = Environ("Username")
Sheets("2025 Rebates").Range("A3").AutoFilter Field:=3, Criteria1:=Cells(2, 6).Value ' this line filters by a cell - A3 is the title line, 3 is the column to filter Cells = column and row number for the cell to filter'
ActiveSheet.Protect "Password"
End Sub
Many thanks
jdhfch
I am trying to create a VBA project that will run on opening a password protected workbook. I want it to populate the username in E1, then to use that username to force filtering Column C, based on a lookup in cell F2 (looking up their actual name based on E1). This is the code I am using, it all works in isolation, but when put together, the Auto filter isn't running. Can anyone help me, please?
Private Sub Workbook_Open()
ActiveSheet.Unprotect "Password"
Dim strUN As String
strUN = Environ("Username")
Worksheets(1).Range("E1").Value = Environ("Username")
Sheets("2025 Rebates").Range("A3").AutoFilter Field:=3, Criteria1:=Cells(2, 6).Value ' this line filters by a cell - A3 is the title line, 3 is the column to filter Cells = column and row number for the cell to filter'
ActiveSheet.Protect "Password"
End Sub
Many thanks
jdhfch