VBA Excel SendKeys in Loop is not Working

JrExceler

New Member
Joined
Nov 18, 2016
Messages
17
I have some problems with this code below,
It's not doing what I expect
I want this code to active an add in to update my main sheet and then goes to the next sheet and update also using the same key combination until page 6,

What I get is that first goes to the page 6 and then performs the key combination 6 times :laugh:

I appreciate if you can give me some advice of what I'm doing wrong,

Code:
Sub UpdateandChange()
   Dim i As Integer

 Worksheets("FirstSheet").Activate

for i= 1 to 6
 
    SendKeys "%XSR"
    
    On Error Resume Next
 Sheets(ActiveSheet.Index + 1).Activate
 If Err.Number <> 0 Then Sheets(1).Activate
 
   Next i

End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Sorry to write again,
I tried to do it without the loop but it's still not working.
I need this to apply to 30 sheets.
A little help will be highly appreciated.

Thank you
 
Upvote 0
Just to move up and mention that I still cannot find the solution,
A little help or guideline will be highly appreciated.

Thanks in advance
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,174
Members
452,615
Latest member
bogeys2birdies

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