LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Need help Cleaning up Code

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cleaning Product Code list mike meyer Excel Worksheet Functions 6 April 11th 05 08:15 PM
Cleaning up some VB Ton Taetsch Excel Programming 1 November 16th 04 12:53 AM
Help with shortening/cleaning some code please roy Excel Programming 3 June 3rd 04 11:49 PM
Cleaning up data ali Excel Programming 5 December 23rd 03 04:22 PM
VBA Code -- Cleaning Data Craig[_8_] Excel Programming 2 December 12th 03 12:21 AM


All times are GMT +1. The time now is 03:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"