Excel Marco Keep on Looping

  • Thread starter Thread starter Legacy 185509
  • Start date Start date
L

Legacy 185509

Guest
Hi
I have Macro that runs automatically when file is open
but I want to run once only but this code is repeating itself again again intead of running just once
please help
thank you
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.OnTime Now + TimeValue("00:00:15"), "Mail_Selection"
'Application.OnTime TimeValue("08:52:00"), "Mail_Selection"
End Sub

second line is commented out, I am using windows task schedule to open the file and stuff
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
In the workbook Events select Open then call your macro by its name. Open the workbook use Alt + F11 then double click thisworkbook on the left in the Project Window, at the top select the Object down arrow and select Workbook this should the give you the Open Event on the right.

Private Sub Workbook_Open()
Call Mail_Selection
End Sub

You then need to comment out the other code.
 
Upvote 0
In the workbook Events select Open then call your macro by its name. Open the workbook use Alt + F11 then double click thisworkbook on the left in the Project Window, at the top select the Object down arrow and select Workbook this should the give you the Open Event on the right.



You then need to comment out the other code.

Hey
After Changing from General to Worksheet
it put this code there automactically
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
 
Upvote 0
see this works but it would call the method everytime I click anywhere on the worksheet
 
Upvote 0
No not the worksheet but workbook Events....

You will have to comment out the Worksheet Event and look at the instructions I suggested for the Workbook Event.
 
Upvote 0
I did follow what you told me
herei s the screenshot of my VBA Editor
255mfex.jpg


sorry I dont know if I am right, is the the one under sheet9 ?
 
Last edited by a moderator:
Upvote 0
Did you double click the item that says thisWorkbook, below sheet 9, your screen shot indicates that it is still one of the other sheets.
 
Upvote 0
Thanx alot it worked like charm
I was getting tensed that I don't have what you asked me to look for lol
thanx again
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,176
Members
452,893
Latest member
denay

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