Hello,
I am new to macros and currently working on a file that is an export from another application. The macro is basically to add lines, reformat, etc. While it is not complicated (for those who are familiar with macros) it does have a lot of steps.
The issue I am having is with trying to format the columns as percentage, currency, etc. When I run the macro as is, it selects columns A-J, instead of just the individual column. At the end of that section, however, the formatting for columns K - N are fine. The section in red is the section I am having issues with.
Any help will be greatly appreciated!!
![]()
Sub Salesreports() ' Rows("2:3").EntireRow.Delete Columns("C:C").EntireColumn.Delete Columns("E:E").Insert Shift:=xlToRight Columns("H:H").Insert Shift:=xlToRight Cells.Select Rows("1:2").Select Selection.UnMerge Columns("A:B").Select Selection.Hyperlinks.Delete With Selection.Font .Name = "Verdana" .Size = 10 End With Range("E3").Select ActiveCell.FormulaR1C1 = "Single Qty - Variance" Range("H3").Select ActiveCell.FormulaR1C1 = "Sales - Variance" Range("K3").Select ActiveCell.FormulaR1C1 = "Cost - Variance" Range("L3").Select ActiveCell.FormulaR1C1 = "Profit- Current" Range("M3").Select ActiveCell.FormulaR1C1 = "Profit - Prior" Range("N3").Select ActiveCell.FormulaR1C1 = "Profit - Variance" Range("N2").Select Rows("3:3").Select With Selection .WrapText = True Columns("K:K").Select Selection.ColumnWidth = 9 Columns("A:N").Select Selection.Borders(xlDiagonalDown).LineStyle = xlNone Selection.Borders(xlDiagonalUp).LineStyle = xlNone With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .ThemeColor = 1 .TintAndShade = -0.14996795556505 .Weight = xlThin End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .ThemeColor = 1 .TintAndShade = -0.14996795556505 .Weight = xlThin End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .ThemeColor = 1 .TintAndShade = -0.14996795556505 .Weight = xlThin End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .ThemeColor = 1 .TintAndShade = -0.14996795556505 .Weight = xlThin End With With Selection.Borders(xlInsideVertical) .LineStyle = xlContinuous .ThemeColor = 1 .TintAndShade = -0.14996795556505 .Weight = xlThin End With With Selection.Borders(xlInsideHorizontal) .LineStyle = xlContinuous .ThemeColor = 1 .TintAndShade = -0.14996795556505 .Weight = xlThin End With Range("H4").Select ActiveCell.FormulaR1C1 = "=(RC[-2]-RC[-1])/RC[-1]" Range("K4").Select ActiveCell.FormulaR1C1 = "=(RC[-2]-RC[-1])/RC[-1]" Range("L4").Select ActiveCell.FormulaR1C1 = "=RC[-6]-RC[-3]" Range("M4").Select ActiveCell.FormulaR1C1 = "=RC[-6]-RC[-3]" Range("N4").Select ActiveCell.FormulaR1C1 = "=(RC[-2]-RC[-1])/RC[-1]" Range("E4").Select ActiveCell.FormulaR1C1 = "=(RC[-2]-RC[-1])/RC[-1]" Range("C4").Select Selection.NumberFormat = "#,##0" Range("D4").Select Selection.NumberFormat = "#,##0" End With Columns("E:E").Select Selection.NumberFormat = "0.00%" Columns("F:G").Select Selection.NumberFormat = "$#,##0.00_);($#,##0.00)" Columns("H:H").Select Selection.NumberFormat = "0.00%" Columns("I:J").Select Selection.NumberFormat = "$#,##0.00_);($#,##0.00)" Columns("K:K").Select Selection.NumberFormat = "0.00%" Columns("L:M").Select Selection.NumberFormat = "$#,##0.00_);($#,##0.00)" Columns("N:N").Select Selection.NumberFormat = "0.00%"Range("A1:N1").Select With Selection .HorizontalAlignment = xlCenter End With Selection.Merge Rows("1:1").Select With Selection.Font .Size = 12 End With Selection.RowHeight = 30 End Sub
Bookmarks