squippe
07-29-2016, 04:21 AM
How can I run the following procedures for each sheet:
Sub Test()
'
' Test Macro
' Add titles
'
'
Rows("1:1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Font.Bold = True
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
End With
ActiveWindow.FreezePanes = True
Range("F1").Select
ActiveCell.FormulaR1C1 = "Konttori nro"
Range("J1").Select
ActiveWindow.SmallScroll Down:=-12
ActiveCell.FormulaR1C1 = "AA"
Range("K1").Select
ActiveCell.FormulaR1C1 = "BB"
Range("L1").Select
ActiveCell.FormulaR1C1 = "CC"
Range("M1").Select
ActiveCell.FormulaR1C1 = "DD"
Range("N1").Select
ActiveCell.FormulaR1C1 = "EE"
Range("P1").Select
ActiveCell.FormulaR1C1 = "FF"
Range("Q1").Select
ActiveCell.FormulaR1C1 = "GG"
Range("X1").Select
ActiveCell.FormulaR1C1 = "HH"
Range("AB1").Select
ActiveCell.FormulaR1C1 = "II"
Range("AC1").Select
ActiveCell.FormulaR1C1 = "Asiakas"
Range("AD1").Select
ActiveCell.FormulaR1C1 = "C/O"
Range("AE1").Select
ActiveCell.FormulaR1C1 = "C/O 2"
Range("AF1").Select
ActiveCell.FormulaR1C1 = "Kieli"
Range("AG1").Select
ActiveCell.FormulaR1C1 = "Postiosoite"
Range("AH1").Select
ActiveCell.FormulaR1C1 = "Postinumero"
Range("AI1").Select
ActiveCell.FormulaR1C1 = "Kaupunki"
Range("AJ1").Select
ActiveCell.FormulaR1C1 = "Maa"
Range("AY1").Select
ActiveCell.FormulaR1C1 = "RR"
Range("AZ1").Select
ActiveCell.FormulaR1C1 = "TT"
Sub Test()
'
' Test Macro
' Add titles
'
'
Rows("1:1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Font.Bold = True
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
End With
ActiveWindow.FreezePanes = True
Range("F1").Select
ActiveCell.FormulaR1C1 = "Konttori nro"
Range("J1").Select
ActiveWindow.SmallScroll Down:=-12
ActiveCell.FormulaR1C1 = "AA"
Range("K1").Select
ActiveCell.FormulaR1C1 = "BB"
Range("L1").Select
ActiveCell.FormulaR1C1 = "CC"
Range("M1").Select
ActiveCell.FormulaR1C1 = "DD"
Range("N1").Select
ActiveCell.FormulaR1C1 = "EE"
Range("P1").Select
ActiveCell.FormulaR1C1 = "FF"
Range("Q1").Select
ActiveCell.FormulaR1C1 = "GG"
Range("X1").Select
ActiveCell.FormulaR1C1 = "HH"
Range("AB1").Select
ActiveCell.FormulaR1C1 = "II"
Range("AC1").Select
ActiveCell.FormulaR1C1 = "Asiakas"
Range("AD1").Select
ActiveCell.FormulaR1C1 = "C/O"
Range("AE1").Select
ActiveCell.FormulaR1C1 = "C/O 2"
Range("AF1").Select
ActiveCell.FormulaR1C1 = "Kieli"
Range("AG1").Select
ActiveCell.FormulaR1C1 = "Postiosoite"
Range("AH1").Select
ActiveCell.FormulaR1C1 = "Postinumero"
Range("AI1").Select
ActiveCell.FormulaR1C1 = "Kaupunki"
Range("AJ1").Select
ActiveCell.FormulaR1C1 = "Maa"
Range("AY1").Select
ActiveCell.FormulaR1C1 = "RR"
Range("AZ1").Select
ActiveCell.FormulaR1C1 = "TT"