VBA in macros

clare_voiant

Board Regular
Joined
Mar 20, 2002
Messages
76
Hello....

i have the following code created by a macro. if i run this code now, it does the same thing again (which it is sposed to do) can i now replace the cell range with some code which will select the next cells down as aposed to a named cell so it will automate the rest of the workbook setup? and if yes, how will i make it stop when it gets to the last name in the range?

sheets("Template").Copy Before:=Sheets(3)
Sheets("Totals").Select
Range("A4").Select
Selection.Copy
Sheets("Template (2)").Select
Range("A3").Select
ActiveSheet.Paste Link:=True
Sheets("Totals").Select
Range("B4").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Template (2)").Select
Range("A6").Select
ActiveSheet.Paste Link:=True
Range("A19").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Totals").Select
Range("C4").Select
ActiveSheet.Paste Link:=True
Sheets("Template (2)").Select
ActiveWindow.SmallScroll Down:=6
Range("A31").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Totals").Select
Range("D4").Select
ActiveSheet.Paste Link:=True
Sheets("Template (2)").Select
ActiveWindow.SmallScroll Down:=23
Range("B54").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Totals").Select
Range("E4").Select
ActiveSheet.Paste Link:=True
Sheets("Template (2)").Select
Range("D54").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Totals").Select
Range("F4").Select
ActiveSheet.Paste Link:=True
Range("A4").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Template (2)").Select
Sheets("Template (2)").Name = "Allan Hudson"
Sheets("Totals").Select
Range("A5").Select
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,123
Yep - you can use a FOR EACH NEXT loop - that will loop through a specified range - when it reaches the end of the range it will stop.
 

Forum statistics

Threads
1,181,906
Messages
5,932,730
Members
436,856
Latest member
s4shubro

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