nutritiouspig
Well-known Member
- Joined
- Jan 8, 2003
- Messages
- 615
I'm extremely new to VBA (just got a book on it), and was wondering if this would be easy to rewrite, or if there were some quick fixes that could be applied to it, in order to make it run a bit more efficiently.
Thanks,
S.
Sub Format()
Sheets("Output_Sheet").Select
Range("A1:K82").Select
Selection.Delete
Sheets("Data_Sheet").Select
Columns("A:A").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Output_Sheet").Select
Range("A1").Select
ActiveSheet.Paste
Range("A1:A27,A29:A31,A59:A74").Select
Range("A59").Activate
Application.CutCopyMode = False
Selection.Delete
Range("A1:A34").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(28, 1), Array(49, 1), Array(55, 1), Array(60, 1))
Selection.Delete Shift:=xlToLeft
Columns("A:A").EntireColumn.AutoFit
Range("F34").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-32]C[-2]:R[-25]C[-2],R[-23]C[-2]:R[-1]C[-2])"
Range("G34").Select
ActiveCell.FormulaR1C1 = "=0.295-RC[-1]"
Range("G34").Select
Selection.NumberFormat = "0.00%"
Range("F33").Select
ActiveCell.FormulaR1C1 = "Total Shrinkage Used"
Range("G33").Select
ActiveCell.FormulaR1C1 = "Shrinkage Available"
Range("F33:G34").Select
With Selection
.HorizontalAlignment = xlCenter
End With
Columns("F:G").EntireColumn.AutoFit
Range("F34").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="0.295"
With Selection.FormatConditions(1).Font
.Bold = True
.ColorIndex = 2
End With
Selection.FormatConditions(1).Interior.ColorIndex = 3
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="0.295"
With Selection.FormatConditions(2).Font
.Bold = True
.ColorIndex = 1
End With
Selection.FormatConditions(2).Interior.ColorIndex = 35
Range("G34").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="0"
With Selection.FormatConditions(1).Font
.Bold = True
.ColorIndex = 1
End With
Selection.FormatConditions(1).Interior.ColorIndex = 35
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="0"
With Selection.FormatConditions(2).Font
.Bold = True
.ColorIndex = 2
End With
Selection.FormatConditions(2).Interior.ColorIndex = 3
With Range("F33:G34").Select
With Selection.Borders
.LineStyle = xlContinuous
.Weight = xlThin
End With
End With
End Sub
Thanks,
S.
Sub Format()
Sheets("Output_Sheet").Select
Range("A1:K82").Select
Selection.Delete
Sheets("Data_Sheet").Select
Columns("A:A").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Output_Sheet").Select
Range("A1").Select
ActiveSheet.Paste
Range("A1:A27,A29:A31,A59:A74").Select
Range("A59").Activate
Application.CutCopyMode = False
Selection.Delete
Range("A1:A34").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(28, 1), Array(49, 1), Array(55, 1), Array(60, 1))
Selection.Delete Shift:=xlToLeft
Columns("A:A").EntireColumn.AutoFit
Range("F34").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-32]C[-2]:R[-25]C[-2],R[-23]C[-2]:R[-1]C[-2])"
Range("G34").Select
ActiveCell.FormulaR1C1 = "=0.295-RC[-1]"
Range("G34").Select
Selection.NumberFormat = "0.00%"
Range("F33").Select
ActiveCell.FormulaR1C1 = "Total Shrinkage Used"
Range("G33").Select
ActiveCell.FormulaR1C1 = "Shrinkage Available"
Range("F33:G34").Select
With Selection
.HorizontalAlignment = xlCenter
End With
Columns("F:G").EntireColumn.AutoFit
Range("F34").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="0.295"
With Selection.FormatConditions(1).Font
.Bold = True
.ColorIndex = 2
End With
Selection.FormatConditions(1).Interior.ColorIndex = 3
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="0.295"
With Selection.FormatConditions(2).Font
.Bold = True
.ColorIndex = 1
End With
Selection.FormatConditions(2).Interior.ColorIndex = 35
Range("G34").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="0"
With Selection.FormatConditions(1).Font
.Bold = True
.ColorIndex = 1
End With
Selection.FormatConditions(1).Interior.ColorIndex = 35
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="0"
With Selection.FormatConditions(2).Font
.Bold = True
.ColorIndex = 2
End With
Selection.FormatConditions(2).Interior.ColorIndex = 3
With Range("F33:G34").Select
With Selection.Borders
.LineStyle = xlContinuous
.Weight = xlThin
End With
End With
End Sub