I'll be able to help if you post a sample of the data you're trying to sort.
I am experiencing the same type of problem on code I have written before but now trying to put in a longer more extensive macro..
The entire code is:
Dim n As Integer
Worksheets("obssum").Activate
'delete any rows without a "class" or with a heading
Range("b:b").Select
Do Until ActiveCell.Offset(0, -1).Value = ""
If Len(ActiveCell.Value) = 1 Or ActiveCell.Value = "" Then
ActiveCell.EntireRow.Delete
Else
ActiveCell.Offset(1).Select
End If
Loop
'insert columns and add headings
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight
ActiveWindow.ScrollRow = 1
Range("C1").Select
ActiveCell.FormulaR1C1 = "Divison"
Range("D1").Select
ActiveCell.FormulaR1C1 = "Category"
Range("B2").Select
'count rows of worksheet
Range("a:a").Select
n = Application.CountA(Selection)
'Vloopup to add product class information
Range("c2").Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC2,[prodclasslist.xls]Sheet1!R2C1:R385C5,2,false)"
Range("C2").Select
Selection.Copy
Range("D2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC2,[prodclasslist.xls]Sheet1!R2C1:R385C5,3,false)"
Range("D2").Select
Selection.Copy
Range("C2:d2").Select
Selection.Copy
ActiveWindow.LargeScroll Down:=-1
Range("C3:d" & n).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("a1").Select
Selection.Columns.AutoFit
'
the data I am working with is:
A CLASS QTY INVVAL USAGE THISMO LASTMO CHG
100 25 677 5 0 0 0
100 25 677 5 0 0 0
100 B18 16 27631 106 2935 1481 -1454
100 B28 60 48734 453 0 0 0
100 B 76 76365 559 2935 1481 -1454
100 C0A 55 54437 143 8774 10131 1357
100 C00 179 224868 943 1381 1381 0
100 C10 135 233779 954 666 666 0
100 C11 26 449204 34 43337 35421 -7916
100 C13 8 72904 21 0 0 0
100 C2A 8 22972 6 9416 35017 25601
100 C20 17 82714 78 30775 30775 0
100 C30 4 4987 29 1209 1700 491
100 C5A 22 221681 171 24679 14675 -10004
I am trying to combine several macros onto one page -- this same code used to work before I tried this.
I am stumped as to why this is happening