F
Faboboren
I am running some codes for 15 sheets that I have recorded them and I want to
write the codes down in simpler instructions. Please any ideas to solve that?
Thanks
Macro 1: I am running this code for 14 different ranges in 15 sheets (first
instruction is to delete 16 sheet that no needed)
Sub Formatline1()
Sheets("WSP_TOC").Select
ActiveWindow.SelectedSheets.Delete
Sheets("WSP_Sheet1").Select
Range("A6:C6").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Macro 2
Sub Color()
'
' Color Macro
' Macro recorded 5/6/2008 by faborenh
'
'
Sheets("WSP_Sheet1").Select
Range("B6:C6").Select
Selection.Interior.ColorIndex = 8
Range("A7:A10").Select
Selection.Interior.ColorIndex = 44
Range("A11:A14").Select
Selection.Interior.ColorIndex = 35
Range("A15:A18").Select
Selection.Interior.ColorIndex = 33
Range("A19:A22").Select
Selection.Interior.ColorIndex = 36
Range("A23:A25").Select
Selection.Interior.ColorIndex = 4
Range("A26:A29").Select
Selection.Interior.ColorIndex = 39
Range("A30:A33").Select
Selection.Interior.ColorIndex = 3
Range("A34:A36").Select
Selection.Interior.ColorIndex = 42
Range("A37:A39").Select
Selection.Interior.ColorIndex = 46
Range("A40:A42").Select
Selection.Interior.ColorIndex = 43
Range("A43:A45").Select
Selection.Interior.ColorIndex = 38
Range("A46:A48").Select
Selection.Interior.ColorIndex = 8
Range("A49:A52").Select
Selection.Interior.ColorIndex = 6
Macro 3
Sub ConditionalFormat()
'
' ConditionalFormat Macro
' Macro recorded 5/6/2008 by faborenh
'
'
Sheets("WSP_Sheet1").Select
Range("C7:C52").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="0"
Selection.FormatConditions(1).Font.ColorIndex = 3
Macro 4
Sub Letter12andBold()
'
' Letter12andBold Macro
' Macro recorded 5/6/2008 by faborenh
'
'
Sheets("WSP_Sheet1").Select
Range("A6:C52").Select
With Selection.Font
.Name = "Arial"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With
Selection.Font.Bold = False
Selection.Font.Bold = True
Macro 5
Sub Adjust1column()
'
' HAdjust1column Macro
' Macro recorded 2006-11-23 by faborenh
'
'
Sheets("WSP_Sheet1").Select
Columns("A:A").EntireColumn.AutoFit
Macro 6
Sub Deselect()
'
' FDeselect Macro
' Macro recorded 2006-11-23 by faborenh
'
'
Range("C1").Select
Sheets("WSP_Sheet15").Select
Macro 7
Sub Pagesetup()
'
' GPagesetup Macro
' Macro recorded 2006-11-23 by faborenh
'
'
Sheets("WSP_Sheet1").Select
With ActiveSheet.Pagesetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.Pagesetup.PrintArea = "$A$1:$C$55"
With ActiveSheet.Pagesetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
write the codes down in simpler instructions. Please any ideas to solve that?
Thanks
Macro 1: I am running this code for 14 different ranges in 15 sheets (first
instruction is to delete 16 sheet that no needed)
Sub Formatline1()
Sheets("WSP_TOC").Select
ActiveWindow.SelectedSheets.Delete
Sheets("WSP_Sheet1").Select
Range("A6:C6").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Macro 2
Sub Color()
'
' Color Macro
' Macro recorded 5/6/2008 by faborenh
'
'
Sheets("WSP_Sheet1").Select
Range("B6:C6").Select
Selection.Interior.ColorIndex = 8
Range("A7:A10").Select
Selection.Interior.ColorIndex = 44
Range("A11:A14").Select
Selection.Interior.ColorIndex = 35
Range("A15:A18").Select
Selection.Interior.ColorIndex = 33
Range("A19:A22").Select
Selection.Interior.ColorIndex = 36
Range("A23:A25").Select
Selection.Interior.ColorIndex = 4
Range("A26:A29").Select
Selection.Interior.ColorIndex = 39
Range("A30:A33").Select
Selection.Interior.ColorIndex = 3
Range("A34:A36").Select
Selection.Interior.ColorIndex = 42
Range("A37:A39").Select
Selection.Interior.ColorIndex = 46
Range("A40:A42").Select
Selection.Interior.ColorIndex = 43
Range("A43:A45").Select
Selection.Interior.ColorIndex = 38
Range("A46:A48").Select
Selection.Interior.ColorIndex = 8
Range("A49:A52").Select
Selection.Interior.ColorIndex = 6
Macro 3
Sub ConditionalFormat()
'
' ConditionalFormat Macro
' Macro recorded 5/6/2008 by faborenh
'
'
Sheets("WSP_Sheet1").Select
Range("C7:C52").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="0"
Selection.FormatConditions(1).Font.ColorIndex = 3
Macro 4
Sub Letter12andBold()
'
' Letter12andBold Macro
' Macro recorded 5/6/2008 by faborenh
'
'
Sheets("WSP_Sheet1").Select
Range("A6:C52").Select
With Selection.Font
.Name = "Arial"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With
Selection.Font.Bold = False
Selection.Font.Bold = True
Macro 5
Sub Adjust1column()
'
' HAdjust1column Macro
' Macro recorded 2006-11-23 by faborenh
'
'
Sheets("WSP_Sheet1").Select
Columns("A:A").EntireColumn.AutoFit
Macro 6
Sub Deselect()
'
' FDeselect Macro
' Macro recorded 2006-11-23 by faborenh
'
'
Range("C1").Select
Sheets("WSP_Sheet15").Select
Macro 7
Sub Pagesetup()
'
' GPagesetup Macro
' Macro recorded 2006-11-23 by faborenh
'
'
Sheets("WSP_Sheet1").Select
With ActiveSheet.Pagesetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.Pagesetup.PrintArea = "$A$1:$C$55"
With ActiveSheet.Pagesetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With