I have a pop up that opens every time i activate a particular sheet. I activate the…
- User
I have a pop up that opens every time i activate a particular sheet. I activate the sheet very often. Is there a way of preventing the popup from opening within the last 60 minutes it was last opened
- Assistant
Yes, you can prevent the popup from opening within the last 60 minutes it was last opened by using VBA code. Here's an example code that you can use:
Private Sub Worksheet_Activate() 'Define variables Dim LastOpened As Date Dim CurrentTime As Date 'Get the last opened time from a cell in the worksheet LastOpened = Range("A1").Value 'Get the current time CurrentTime = Now() 'Compare the difference in minutes between last opened time and current time If DateDiff("n", LastOpened, CurrentTime) >= 60 Then 'Open the popup window MsgBox "Your Popup Message!" 'Update the value in the cell to the current time Range("A1").Value = CurrentTime End If End SubThis code assumes that you have a cell (in this example, A1) that contains the last time the popup was opened. The code then compares the difference in minutes between the last opened time and the current time. If the difference is greater than or equal to 60 minutes, the popup will open and the cell value will be updated to the current time. If the difference is less than 60 minutes, the popup will not open.