C
Cheryl
Will a macro close print preview. I had a macro perform other tasks, and then
open in print preview, however it will not close the preview. I really need
to. What am I doing wrong. I am pasting the macro below.
--
Cheryl/
Sub ConvertData()
'
' ConvertData Macro
' Converts date, time, temperature to Celcius, bolds, averages celcius temp,
print preview
'
' Keyboard Shortcut: Ctrl+d
'
Columns("A:A").Select
Selection.NumberFormat = "m/d/yyyy"
Columns("B:B").Select
Selection.NumberFormat = "h:mm;@"
Columns("C:C").EntireColumn.AutoFit
Range("D1").Select
ActiveCell.FormulaR1C1 = "Celcius"
With ActiveCell.Characters(Start:=1, Length:=7).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("D2").Select
ActiveCell.FormulaR1C1 = "=5/9*(RC[-1]-32)"
Range("D2").Select
Selection.AutoFill Destination:=Range("D226"), Type:=xlFillDefault
Range("D226").Select
Columns("D").Select
Selection.NumberFormat = "0.0"
Range("A11").Select
Selection.Font.Bold = True
Columns("C:C").ColumnWidth = 11
Range("A27").Select
ActiveCell.FormulaR1C1 = "Average"
With ActiveCell.Characters(Start:=1, Length:=7).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("A27").Select
Selection.Font.Bold = True
Range("D27").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(R[-25]C:R[-1]C)"
Range("D27").Select
Selection.Font.Bold = True
Range("F1").Select
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "MediTrax Controls"
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = "Cheryl Sarver"
.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 = True
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = False
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
ActiveWindow.SelectedSheets.PrintPreview
End Sub
open in print preview, however it will not close the preview. I really need
to. What am I doing wrong. I am pasting the macro below.
--
Cheryl/
Sub ConvertData()
'
' ConvertData Macro
' Converts date, time, temperature to Celcius, bolds, averages celcius temp,
print preview
'
' Keyboard Shortcut: Ctrl+d
'
Columns("A:A").Select
Selection.NumberFormat = "m/d/yyyy"
Columns("B:B").Select
Selection.NumberFormat = "h:mm;@"
Columns("C:C").EntireColumn.AutoFit
Range("D1").Select
ActiveCell.FormulaR1C1 = "Celcius"
With ActiveCell.Characters(Start:=1, Length:=7).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("D2").Select
ActiveCell.FormulaR1C1 = "=5/9*(RC[-1]-32)"
Range("D2").Select
Selection.AutoFill Destination:=Range("D226"), Type:=xlFillDefault
Range("D226").Select
Columns("D").Select
Selection.NumberFormat = "0.0"
Range("A11").Select
Selection.Font.Bold = True
Columns("C:C").ColumnWidth = 11
Range("A27").Select
ActiveCell.FormulaR1C1 = "Average"
With ActiveCell.Characters(Start:=1, Length:=7).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("A27").Select
Selection.Font.Bold = True
Range("D27").Select
ActiveCell.FormulaR1C1 = "=AVERAGE(R[-25]C:R[-1]C)"
Range("D27").Select
Selection.Font.Bold = True
Range("F1").Select
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "MediTrax Controls"
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = "Cheryl Sarver"
.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 = True
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = False
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
ActiveWindow.SelectedSheets.PrintPreview
End Sub