iknowyourthere
New Member
- Joined
- Dec 2, 2008
- Messages
- 13
Never noticed the problem before but with 2007 it has stuck out. when I run this macro that i use from just recording deleting and moving things i notice that my last cell is like 1000000+ but data ends at 2-5K. I have tried to use the code to clean up activesheet.usedrange but Ctlr-end still brings me to G1million because the record wizard selected col. Can this be written to be dynamic as the amount of data changes every month but never exceeds the G col
Code:
Range("A1:H6").Select
Selection.Delete Shift:=xlUp
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Columns("F:F").Select
Selection.Delete Shift:=xlToLeft
Columns("D:D").Select
Selection.Copy
Columns("E:E").Select
ActiveSheet.Paste
Columns("D:D").Select
Application.CutCopyMode = False
Selection.ClearContents
Columns("A:A").Select
Selection.Replace What:=";*", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Columns("B:B").Select
Selection.NumberFormat = "0"
Columns("A:A").ColumnWidth = 54
Columns("A:A").ColumnWidth = 67.86
Selection.ColumnWidth = 15.14
Columns("C:C").Select
Selection.ColumnWidth = 26.71
Columns("E:E").Select
Selection.Replace What:="c", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.NumberFormat = "0.00"
Range("G2").Select
Selection.NumberFormat = "0.00"
ActiveCell.FormulaR1C1 = "-1"
Range("G2").Select
Selection.Copy
Columns("E:E").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWindow.DisplayZeros = False
Columns("A:E").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("B1") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal