Hi, this is my first post so hoping I do this right. I am trying to run a SUB in Microsoft Visual Basic for Applications, but I keep getting the following error: "Compile Error: With object must be User-Defined Type, Object or Variant." The SUB is attempting to freeze panes in many worksheets within an Excel workbook (Excel 2010). This is the remedy posted by Microsoft, but I am not sure what this means or what I need to do: "The With...End With block can't be used with all variable types. This error has the following cause and solution: You tried to use a variable that was not of Object type, user-defined type, or Variant type containing an object within a With block. Check to see if you misspelled the name of the object, user-defined type, or Variant variable." I am new to VB so I don't know what this means. I just know this worked last year and now it doesn't. Is there possibly a setting that needs to be checked in VB? I found one solution for another user was to "check" something that was unchecked in Tools>References, but I am not sure what needs to be checked that isn't already. Thanks, my SUB is below:
[Sub FPR_15_freeze_panes()
Dim ws As Worksheet
For Each ws In Worksheets
Range("G2").Select
With ActiveWindow.FreezePanes = True
End With
Next ws
MsgBox ("Done!")]