Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The Following Code cleans up data imported from a scheduling program. I
have used the recorder and snippets of code I've found to create the following. I'm sure there is a more efficient way to write this code. I have begun cleaning it up but I'm sure there must be an alternate way to delete the columns that allows for the fact that the columns are shifted over. For example because "Col's B & D" are deleted "Col. E" becomes "Col C" when it began as "Col E". Any help would be appreciated. Joel Sub Cleanup_Convert() 'This Begins the Cleanup Process Worksheets("Export").Activate Range("1:2").Delete Range("B:b").Delete Range("D:D").Delete Range("C:C").Delete Range("G:H").Delete Range("A1").Value = ("Discipline") Range("B1").Value = ("Week Beginning") Range("C1").Value = ("Early Ave.") Range("D1").Value = ("Early Cumm.") Range("E1").Value = ("Late Ave.") Range("F1").Value = ("Late Cumm.") 'This Adds the Planned Column Range("H1") = "Planned Ave. Manpower" Range("H2").FormulaR1C1 = "=AVERAGE(RC[-4],RC[-2])" Range("H2").AutoFill Destination:=Range("H2:H18") 'This Converts the Planned Manpower by dividing by the number of Days Worked Rows("1:1").Insert Shift:=xlDown Range("H1").FormulaR1C1 = "5" Range("H1").Copy Range("H3:H19").PasteSpecial Paste:=xlAll Selection.NumberFormat = "0.0" 'This Adds Week Ending Column Range("G2").Value = "Week Ending" Range("G3").Formula = "=B3+6" Range("G3").AutoFill Destination:=Range("G3:G19") Columns("G:G").Columns.AutoFit 'This Adds the Column for Early % based on Cummulative Early Values Range("D1").Formula = "=MAXA(d3:d7000)" Range("I3").Formula = "=d3/d$1" Range("I3").AutoFill Destination:=Range("I3:I19") Range("I2").Value = ("Target Early %") 'This Adds the Column for Late % and calculates based on Cummulative Late Values 'a row is also inserted between column G this allows the CurrentRegion to work 'correctly Range("F1").Formula = "=MAXA(f3:f7000)" Range("j3").Formula = "=F3/F$1" Range("J3").AutoFill Destination:=Range("J3:J19") Range("j2").Value = ("Target Late %") Range("I:J").Select Selection.NumberFormat = "0.0%" 'Wraps and Centers Titles on Row 2 Rows("2:2").Select With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = True End With Worksheets("Charts").Activate End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Cleaning Product Code list | Excel Worksheet Functions | |||
Cleaning up some VB | Excel Programming | |||
Help with shortening/cleaning some code please | Excel Programming | |||
Cleaning up data | Excel Programming | |||
VBA Code -- Cleaning Data | Excel Programming |