I recorded this macro. The purpose is to open a file then reallign
the data into columns and then compute the average and standard
deviation on each col. It is recorded for 28 entries. How does one
set this up to accept ie 55 or 83 or 110 entries with out cutting and
pasting. i would appreciate any help.
Keyboard Shortcut: Ctrl+y
Rows("1:17").Select
Selection.Delete Shift:=xlUp
Rows("1:1").Select
Selection.Insert Shift:=xlDown
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(25, 1), Array(33, 1),
Array(41, 1), Array(49, 1), _
Array(57, 1), Array(65, 1), Array(73, 1), Array(81, 1), Array
(89, 1), Array(97, 1), Array( _
105, 1))
Columns("I:L").Select
Selection.Delete Shift:=xlToLeft
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A1").Select
ActiveCell.FormulaR1C1 = "Item #"
Range("B1").Select
ActiveCell.FormulaR1C1 = "ID SER#"
Range("C1").Select
ActiveCell.FormulaR1C1 = "FLA"
Range("D1").Select
ActiveCell.FormulaR1C1 = "FLC"
Range("E1").Select
ActiveCell.FormulaR1C1 = "PFA"
Range("F1").Select
ActiveCell.FormulaR1C1 = "PFC"
Range("G1").Select
ActiveCell.FormulaR1C1 = "LLA"
Range("H1").Select
ActiveCell.FormulaR1C1 = "LLC"
Range("I1").Select
ActiveCell.FormulaR1C1 = "FLS"
Range("C1:I29").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Rows("30:31").Select
Selection.Delete Shift:=xlUp
Range("A2").Select
ActiveCell.FormulaR1C1 = "1"
Range("A3").Select
ActiveCell.FormulaR1C1 = "=R[-2]C+1"
Range("A3").Select
ActiveCell.FormulaR1C1 = "=R[-1]C+1"
Range("A3").Select
Selection.AutoFill Destination:=Range("A3:A29"),
Type:=xlFillDefault
Range("A3:A29").Select
Range("A2:A29").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Range("C30").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(R[-28]C:R[-1]C)"
Selection.Copy
Range("D30:I30").Select
ActiveSheet.Paste
Range("B30").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "X"
Range("B30").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Range("B31").Select
ActiveCell.FormulaR1C1 = "STDEV"
Range("B31").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Range("C31").Select
ActiveCell.FormulaR1C1 = "=STDEV(R[-29]C:R[-2]C)"
Selection.Copy
Range("D31:I31").Select
ActiveSheet.Paste
Range("C31").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("D33").Select
End Sub