I think you mean to deal with Sheet1 not sheet("details")
Try this change
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Intersect(Target, Range("B1:H1")) Is Nothing Then Exit Sub
Dim I&: I = Target.Column
Cancel = True
If I = 2 Then
With Range("B2:H" & Cells(Rows.Count, 2).End(xlUp).Row)
.Sort Key1:=.Cells(1, I - 1), Order1:=xlAscending
End With
Else
With Range("B2:H" & Cells(Rows.Count, 2).End(xlUp).Row)
.Sort Key1:=.Cells(1, I - 1), Order1:=xlDescending
End With
End If
End Sub
Bookmarks