Auto clicking macro button

dp001

New Member
Joined
Mar 6, 2019
Messages
3
Hi

Code:
Sub Button1_Click()
    Range("T23").Select
    Selection.ClearContents
End Sub
Sub test()
    Application.OnTime Now + TimeValue("00:00:10"), "Repeat_VBA"
End Sub

Above is the code I have.

I have created a button which when clicked manually clears the contents in T23, as seen in the top half of the code.

I have written the second half of the code in the hope it will auto click the button every 10 seconds but it doesn't do anything.

Can anyone see what's wrong with this?

Thanks
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Welcome to the Board.

Try:

Code:
Sub Button1_Click()
    Range("T23").ClearContents
End Sub
Sub Repeat_VBA()
    Button1_Click
    Application.OnTime Now + TimeValue("00:00:10"), "Repeat_VBA"
End Sub
 
Upvote 0
Cross posted https://www.excelforum.com/excel-fo...7362-auto-click-macro-button.html#post5078295

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
How are you initiating the second macro? If you just want the first button click to start the process:

Code:
Sub Button1_Click()
    Range("T23").ClearContents
    Application.OnTime Now + TimeValue("00:00:10"), "Button1_Click"
End Sub
How do you plan to end the process? You could monitor a certain cell and if it sees an "x", stop:
Code:
Sub Button1_Click()
    Range("T23").ClearContents
    If Range("T24") = "x" Then Exit Sub
    Application.OnTime Now + TimeValue("00:00:10"), "Button1_Click"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

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