absent-minded coding

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Very busy with different projects for a school...
Tried to solve a little problem without solving it :laugh:
Code:
Private Sub Workbook_Open()
Application.EnableEvents = True
End Sub
OK, this might be an inside joke, somebody else will perhaps take the time to explain if needed: till then it could be an enigma.

have a nice end of the weekend,
Erik
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
If events were not already enabled, the Open event wouldn't trigger.
 
It was to easy for you to see that :-)
Any examples of something stupid you did yourself?
 
I make lots, but I bury them in the back yard.
 
... and drink to forget.
 
Code:
    ActiveSheet.PivotTables("PivotTable3").PivotSelect "", xlDataAndLabel, True
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=IF(ISBLANK($C1),AND(ISBLANK($D1),AND(ISBLANK($E1))))"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority    
With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent3
        .TintAndShade = 0.599963377788629
    End With
    Cells.FormatConditions.Delete
Was trying to colour subtotal rows for the longest time and couldn't figure out why it wouldn't work... might've recorded a bit too much, long day
 
Trying to get the maximum within a range, as well as the data from 2 seconds before and after. About 3AM I gave up, then woke up in the morning realizing why it wasn't returning the maximum, even though Application.Max(Rng) was just fine in debug mode...
Code:
    With Workbooks(df).Worksheets(ds)
 
        For j = 1 To 7
       
            Set Rng = Intersect(.Rows(fdr & ":" & ldr), .Columns(TemperatureCols(j)))
            If Not Rng Is Nothing Then
    
                SummArray((j - 1) * 5 + 9) = .Cells(Application.Match(Application.Max(Rng), Rng, 0) - 2, Rng.Column)
                SummArray((j - 1) * 5 + 10) = .Cells(Application.Match(Application.Max(Rng), Rng, 0) - 1, Rng.Column)
                SummArray((j - 1) * 5 + 11) = .Cells(Application.Match(Application.Max(Rng), Rng, 0), Rng.Column)
                SummArray((j - 1) * 5 + 12) = .Cells(Application.Match(Application.Max(Rng), Rng, 0) + 1, Rng.Column)
                SummArray((j - 1) * 5 + 13) = .Cells(Application.Match(Application.Max(Rng), Rng, 0) + 2, Rng.Column)
       
            End If
       
            Set Rng = Nothing
 
        Next j
 
    End With
 
Code:
Private Sub Workbook_Open()
   Application.EnableEvents = True
End Sub

But curiously this works:
Rich (BB code):
Sub Auto_Open()
  Application.EnableEvents = True
End Sub

And even more curiously - Auto_Open is not working if workbook is opening via Workbooks.Open
 
Last edited:

Forum statistics

Threads
1,223,737
Messages
6,174,206
Members
452,551
Latest member
croud

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top