ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Getting a macro to repeat (https://www.excelbanter.com/excel-discussion-misc-queries/41131-getting-macro-repeat.html)

Hru48

Getting a macro to repeat
 

I have a macro which changes the value of a listbox entry and then
copies its values from one excel sheet to another to be totalled up
later. I need this to be run at least 50 times automatically as I am
currently just hitting run every time.

Maco is below and I would really be gratful for any thoughts on this.

Cheers

Hayley


Sub tesIncrement2()
Range("D108:R108").Select
Selection.Copy
Windows("test").Activate
Range("B1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown
Windows("North_central_agent.xls").Activate
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("Reference").Select
Windows("test").Activate


Range("A1").Select
Selection.Delete Shift:=xlUp
Selection.Copy
Windows("North_central_agent.xls").Activate
Range("H103").Select
ActiveSheet.Paste
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Summary").Select
Windows("test").Activate
Range("B1").Select
Application.CutCopyMode = False
Windows("North_central_agent.xls").Activate

End Sub


--
Hru48
------------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=396939


Excel_Geek


What if you did this?


Sub tesIncrement2()

For x = 1 to 50

Range("D108:R108").Select
Selection.Copy
Windows("test").Activate
Range("B1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown
Windows("North_central_agent.xls").Activate
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("Reference").Select
Windows("test").Activate


Range("A1").Select
Selection.Delete Shift:=xlUp
Selection.Copy
Windows("North_central_agent.xls").Activate
Range("H103").Select
ActiveSheet.Paste
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Summary").Select
Windows("test").Activate
Range("B1").Select
Application.CutCopyMode = False
Windows("North_central_agent.xls").Activate

Next x

End Sub


--
Excel_Geek
------------------------------------------------------------------------
Excel_Geek's Profile: http://www.excelforum.com/member.php...o&userid=26423
View this thread: http://www.excelforum.com/showthread...hreadid=396939


Hru48


Thanks alot! Works like a charm


--
Hru48
------------------------------------------------------------------------
Hru48's Profile: http://www.excelforum.com/member.php...o&userid=24895
View this thread: http://www.excelforum.com/showthread...hreadid=396939



All times are GMT +1. The time now is 08:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com