Euro5
asked on
vba error msg on sheet.activate
I am getting an error on below. Can anyone help?
Sub FORMATREPORT()
Dim rng As Range
Dim LastRow As Long
If A2 = "" Then
MsgBox ("No data meets minimum deficit weight.")
Detail.Activate
End
End If
Application.ScreenUpdating = False
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1:L1").Select
Selection.Font.Bold = True
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Set rng = Application.Intersect(ActiveSheet.UsedRange, Range("A:L"))
rng.SpecialCells(xlCellTypeVisible).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Columns("J:J").Select
Selection.Style = "Comma"
Selection.NumberFormat = "#,##0"
Columns("K:K").Select
Selection.Style = "Currency"
Columns("L:L").Select
Selection.Style = "Currency"
Columns("I:I").Select
Selection.Style = "Comma"
Selection.NumberFormat = "_(* #,##0.0_);_(* (#,##0.0);_(* ""-""??_);_(@_)"
Selection.NumberFormat = "_(* #,##0_);_(* (#,##0);_(* ""-""??_);_(@_)"
Columns("A:A").Select
Selection.NumberFormat = "mm-dd-yyyy"
Columns("A:L").Select
Selection.EntireColumn.AutoFit
LastRow = Cells(Cells.Rows.Count, "J").End(xlUp).Row + 1
Range("K" & LastRow).Formula = "=SUM(K2:K" & LastRow - 1 & ")"
Range("L" & LastRow).Formula = "=SUM(L2:L" & LastRow - 1 & ")"
Application.ScreenUpdating = True
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER