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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,477
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
Maybe for 10 times...
Code:
Sub Loop10()
    Dim i As Long
    For i = 1 To 10
        Application.SendKeys "{ENTER}", True
    Next i
End Sub
 

mole999

Well-known Member
Joined
Oct 23, 2004
Messages
10,524
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
you could put it in a loop

Dim n
for n = 1 to 10
Application.SendKeys "{ENTER}", True
next n
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,066
Messages
5,851,886
Members
431,471
Latest member
netyasser

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
Top