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 ?
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
13,336
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

Moderator
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
 

Watch MrExcel Video

Forum statistics

Threads
1,109,248
Messages
5,527,627
Members
409,777
Latest member
jamilowella

This Week's Hot Topics

Top