How to VBA SendKeys 3times, 4times, 5times etc

VBAIntermediate

New Member
Joined
May 8, 2018
Messages
10
Hey,

Is there a way to write the below more sucinctly

Code:
Application.SendKeys "{ENTER}", True
Application.SendKeys "{ENTER}", True
Application.SendKeys "{ENTER}", True
Application.SendKeys "{ENTER}", True
Application.SendKeys "{ENTER}", True

As depending on what happens I will need to write the above between 3-10 times, is there a way to write that more eloquently than a copy and paste 3times, 4times ect ?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Maybe for 10 times...
Code:
Sub Loop10()
    Dim i As Long
    For i = 1 To 10
        Application.SendKeys "{ENTER}", True
    Next i
End Sub
 
Upvote 0
you could put it in a loop

Dim n
for n = 1 to 10
Application.SendKeys "{ENTER}", True
next n
 
Upvote 0

Forum statistics

Threads
1,214,545
Messages
6,120,132
Members
448,947
Latest member
test111

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