Function does not run until macro has been performed

Excelquestion35

Board Regular
Joined
Nov 29, 2021
Messages
53
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

Currently I have an issue with the sequence on which my functions are performed. I had to update a document with a lot of modules already predefined. I had to insert a new function that empties the drop down list fields every time a new parent is chosen. However, this code only works if a macro is run before.

How can I make sure that the code works everytime without having to first perform a Macro from the modules?

This is the code that I wrote in the corresponding sheet:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$B$14" Then
    Range("B15").Value = " "
    
    End If
    
    If Target.Address = "$B$14" Then
    Range("B25").Value = " "
    
    End If
    
    
    If Target.Address = "$B$15" Then
    Range("B25").Value = " "
    
    End If
    
    
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Application.Sheets("Sheet1").Range("B11", "B14", "B15", "B17", "B21", "B25", "B40", "B41", "B42", "B43", "B45").Value = "" Then
Cancel = True
MsgBox "Save cancelled"
End If
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
There's nothing there that would require running a macro. I can only guess that something has disabled events and the macro you run re-enables them.
 
Upvote 0
Solution
Thank you RoryA, I did not know that that could be the case but I did a ctrl + f on the word events and found indeed that this was turned off. It is working now.
 
Upvote 0

Forum statistics

Threads
1,215,247
Messages
6,123,853
Members
449,129
Latest member
krishnamadison

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