Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
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 |
#3
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Repeat a command in a Macro | Excel Discussion (Misc queries) | |||
repeat macro formula to all cells | Excel Discussion (Misc queries) | |||
Macro to repeat formulas in next row | Excel Discussion (Misc queries) | |||
Date macro | Excel Discussion (Misc queries) | |||
How to program an excel macro to repeat a series of keystrokes? | Excel Discussion (Misc queries) |