I need some help. I am teaching myself how to code in VBA and still have a lot to learn. I have a big block of data that I am trying to sort. I have been able to sort data vertically in the past by vba code. However, this time I want to sort data horizontally. I know my error is in the section labeled " 'organizes columns based of values in row 9 ". I can't figure out how to correct it. Can some one make it work and explain why mine is incorrect?
Cheers,
Demni009
Cheers,
Demni009
Code:
Sub Calc()
Dim c As Integer
'Deletes values and replaces them with a blank cell
ActiveSheet.Rows(9).Delete
Range("A9").EntireRow.Insert
'Where to start summing
c = 4
'Sums values
Do
summed = Application.WorksheetFunction.Sum(Columns(c))
Cells(9, c).Value = summed
c = c + 1
Loop Until Cells(15, c).Value = ""
'organizes columns based of values in row 9
org = Cells(Rows.Count, c).End(xlUp).Row
With Sheets("RGA Data").Cells(Rows.Count, 4).End(xlUp)
.Range("A9:" & Cells(org, c)).Sort _
Key1:=.Range("D9"), Order1:=xlAscending, Orientation:=xlLeftToRight
End With
End Sub