Hi,

I am trying to set up a workbook_open event which will be only running the first time you open the file. In this way, if the macro found a sheet called "LogDetails" the macro will not be executed, else, will create the "LogDetails" sheet.

Private Sub Workbook_Open()

Dim nombrehoja As String

 On Error Resume Next
 
   If BuscarHoja2 = (Worksheets(nombrehoja).Name <> "LogDetails") Then
   
   
   Exit Sub
   
   
   Else
   
     Sheets.Add After:=ActiveSheet
    
     'Create Log details
    ActiveSheet.Name = "LogDetails"
    
    ActiveCell.FormulaR1C1 = "Date"
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "Time"
    Range("C1").Select
    ActiveCell.FormulaR1C1 = "Cell_Address"
    Range("D1").Select
    ActiveCell.FormulaR1C1 = "New_Value"
    Range("E1").Select
    ActiveCell.FormulaR1C1 = "Username"
    Range("F1").Select
    ActiveCell.FormulaR1C1 = "Row_number"
    Range("G1").Select
    ActiveCell.FormulaR1C1 = "Time_dif"
    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent1
        .TintAndShade = -0.249977111117893
        .PatternTintAndShade = 0
    End With
    With Selection.Font
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = 0
    End With
   
    Columns("A:G").EntireColumn.AutoFit
    
   
    
    'Protect log details
  
    ActiveSheet.Protect Password:="JC", DrawingObjects:=True, Contents:=True, Scenarios:=True
    
    ActiveWindow.SelectedSheets.Visible = False
    
    
    End If
    
    
    
End Sub
BUT IT IS NOT WORKING AND THAT IS WHY I ASK FOR HELP PLEASE

THANKS A LOT